Skip to content

batch: timed-out place leaves its browser running, SIGTERM is ignored, and large places slow down #33

Closed

Description

@marcinobel

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.

  1. Timeout does not stop the scrape.
    • Actual: when --location-timeout fires, 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.
  2. Next place fails on the shared profile.
    • Actual: the next place launches a second persistent browser on ~/.revcli/chrome-profile while 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.
  3. SIGTERM does not stop revcli.
    • Actual: kill <pid> (SIGTERM) leaves revcli and its Chromium running; only kill -9 stops 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.
  4. 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.

Steps to reproduce

  1. Sign in once with revcli auth.
  2. Make a file with two place links, where the first has thousands of reviews.
  3. Run revcli batch <file> --headless --location-timeout 60000 -o <dir>.
  4. After the first place times out, the second place fails, and pgrep -fl chrom still shows the first browser.
  5. 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

  1. After a location timeout, the timed-out scrape stops and its browser is closed before the next place starts.
  2. In a batch where place 1 times out, place 2 is scraped and saved.
  3. SIGTERM closes every open browser and exits with a non-zero code within 10 seconds.
  4. 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.
  5. 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-limit option 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-location Promise.race timeout; the losing scrape is never cancelled.
  • src/scraper/browser.ts – the SIGINT cleanup handler and activeContexts; there is no SIGTERM handler.
  • src/scraper/scroller.ts – the collect cycle that calls extractReviews, captureOriginalTexts and expandAllReviews.
  • src/scraper/extractor.ts – the in-page bulk read of review cards.
  • tests/browser/scroll.test.ts and tests/browser/fixtures/maps-page.ts – the local scroll fixture.

Activity

  1. added
    bug
    on Nov 20, 2026
  2. marcinobel commented on Nov 20, 2026

    @marcinobel
    MemberAuthor

    Fixed by #34 (merged into develop as c7eb9c5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions