Repository navigation
Description
Summary
revcli batch cannot finish a long list of places without help. When one place runs past its time limit, the browser for that place keeps running, and the next place then fails because two browsers try to use the same profile. The process also does not stop on a normal stop signal, and places with many reviews get slower and slower to collect. Users who scrape many or large places lose results and must stop and restart the run by hand.
Done when: a batch run with a place that times out goes on to the next place and saves it, kill <pid> stops revcli and its browser, and a large place is collected at a steady pace.
For AI agents
Problem
Seen on develop at 5bc6865 during a 50-place batch, macOS, headless, signed-in profile.
- Timeout does not stop the scrape.
- Actual: when
--location-timeoutfires, batch logs the failure and starts the next place, but the timed-out scrape keeps running and its Chromium stays open. - Expected: the timed-out scrape stops and its browser is closed before the next place starts.
- Actual: when
- Next place fails on the shared profile.
- Actual: the next place launches a second persistent browser on
~/.revcli/chrome-profilewhile the first is still open, and it fails. - Expected: only one browser uses the profile at a time; the places after a timeout are scraped normally.
- Actual: the next place launches a second persistent browser on
- SIGTERM does not stop revcli.
- Actual:
kill <pid>(SIGTERM) leaves revcli and its Chromium running; onlykill -9stops them, and then Chromium must be killed separately. Only SIGINT has a cleanup handler. - Expected: SIGTERM closes the browser and exits with a non-zero code, the same way SIGINT does.
- Actual:
- Collection slows down as a place grows.
-
Actual: reviews per minute fall as the review count grows. Measured with
revcli scrape(same collect loop as batch):Reviews Minutes Reviews per minute 315 3.6 88 630 6.8 93 2,484 47.0 53 4,230 151.4 28 6,420 480 (stopped) 13 -
Expected: time per collect cycle stays roughly flat as the list grows.
-
Suspected cause (hypothesis – confirm before fixing): each cycle reads every rendered review card from the page again (the verbose log shows lines such as
Extracted 1790 reviews from DOM), so the cost of a cycle grows with the number of reviews already loaded.
-
- Frequency: 1–3 always, after any location timeout or SIGTERM. 4 always, on places with thousands of reviews.
- Approach: choose an approach and state your assumption in the PR.
- Prior fix: none known. Sequential scrapes return data from wrong location due to persistent Chrome profile state #4 (cross-place state in the shared profile) and Improve stale scroll detection with backoff and loading spinner awareness #2 (stale-scroll detection) touch nearby code but are different problems.
Steps to reproduce
- Sign in once with
revcli auth. - Make a file with two place links, where the first has thousands of reviews.
- Run
revcli batch <file> --headless --location-timeout 60000 -o <dir>. - After the first place times out, the second place fails, and
pgrep -fl chromstill shows the first browser. - Send
kill <revcli pid>: the process keeps running.
Context
- The profile is a persistent Chromium profile, and Chromium allows one browser per profile directory, so a leftover browser blocks every later place.
- Users run batch unattended for hours, often under a process manager that stops jobs with SIGTERM.
- Each output file must stay complete: a timed-out place must not leave a partial or wrong file behind.
Fix the bug
Write a failing test that reproduces each problem where it can be tested without the live site (fakes, or the local fixtures in tests/browser/), then change the code until it passes. Keep the change to what the fix needs. Do not rewrite shared git history (force-push, rebase, reset).
Acceptance criteria
- After a location timeout, the timed-out scrape stops and its browser is closed before the next place starts.
- In a batch where place 1 times out, place 2 is scraped and saved.
- SIGTERM closes every open browser and exits with a non-zero code within 10 seconds.
- With the scroll fixture at 2,000 reviews, the last 10 collect cycles take at most 2 times as long as the first 10 cycles.
- The new regression tests fail before the fix and pass after it.
Verification
Run npm run typecheck and npm test and include their output in the PR. Also do one live run of steps 1–5 above and paste the output that shows place 2 saved and the process gone after kill. If a check cannot run, say which one and why. Tests are evidence of correct behaviour, not the goal. Do not change, skip or special-case existing tests to make them pass; if a test looks wrong, report it in the PR instead.
Out of scope
- A
--time-limitoption for batch, or other new options. - Running places in parallel.
- Changing the output format or the resume state file.
- New features, unrelated refactors, extra docs or extra test suites. If one would help, mention it at the end of the PR.
Stop and ask when
- The task cannot be done as written (missing file, access or information). Stop and report what is missing; do not work around it.
- The fix needs a change to a public CLI option, a data migration, or a new dependency.
- Criterion 4 cannot be met without changing what is collected (for example skipping reviews).
- The expected behaviour above contradicts what the code or tests show.
Report in the PR
- What was done, criterion by criterion, with the command output that proves each one.
- What was not done, stubbed or left as a TODO – or "nothing".
- Any code copied or reused from elsewhere in the repo, a library, or a prior fix.
- Every check you ran, and any check you could not run, with the reason.
Starting points (verify before use – as of 5bc6865)
src/commands/batch.ts– the per-locationPromise.racetimeout; the losing scrape is never cancelled.src/scraper/browser.ts– theSIGINTcleanup handler andactiveContexts; there is no SIGTERM handler.src/scraper/scroller.ts– the collect cycle that callsextractReviews,captureOriginalTextsandexpandAllReviews.src/scraper/extractor.ts– the in-page bulk read of review cards.tests/browser/scroll.test.tsandtests/browser/fixtures/maps-page.ts– the local scroll fixture.
Activity
fix(batch): stop timed-out places, handle SIGTERM, keep collection fa…
marcinobel commentedon Nov 20, 2026
Fixed by #34 (merged into develop as c7eb9c5).
docs(release): document npm registry lag seen on 0.2.0 and the collec…