Skip to content

fix(drive): stop Chrome and its helpers when the run ends or is terminated - #147

Open
jacoblewisau wants to merge 1 commit into
wheresryan22:mainfrom
jacoblewisau:drive-signal-cleanup
Open

jacoblewisau wants to merge 1 commit into
wheresryan22:mainfrom
jacoblewisau:drive-signal-cleanup

Conversation

@jacoblewisau

Copy link
Copy Markdown

What this changes

  • scripts/drive.mjs stops Chrome and all of its helper processes together: Chrome is spawned in its own process group, one SIGKILL takes the whole group, and the driver waits until nothing of that group is left (bounded at 3 s) before it removes the profile folder. The same stop runs on a normal exit and when the driver itself is terminated (a test's 30 s timeout, Ctrl-C). After a termination it exits by the same signal it received, so callers see the exit status they always did. On Windows the behaviour is unchanged.
  • scripts/drive-signal.test.mjs (new): starts a long wait action, sends SIGTERM once Chrome is running, then asserts that the driver died by SIGTERM, that no process using that profile remains, and that the profile folder is gone. Skipped on Windows.
  • CHANGELOG.md: a line under Unreleased / Fixed.

Why

A terminated driver run used to leave its headless Chrome running. Under node --test scripts/*.test.mjs (the CI command, which runs test files in parallel), every browser test that hit its 30 s limit leaked a Chrome, each leak slowed the next test, and the run cascaded. On an 8-core laptop: 538 orphaned Chrome processes, a load average of 622, every browser test failing. The same suite serialised passed 289 of 290.

A normal exit also left near-empty profile folders behind (Default/Reporting and NEL-journal, Default/Network Action Predictor-journal and similar), written by Chrome processes that were still shutting down when the folder was removed.

Measured with this change on the same machine, full suite in parallel: 291 of 291 pass in 106 s, 0 Chrome processes and 0 profile folders left afterwards. The new test fails against the previous driver with timed out waiting for Chrome to be gone.

Checks

Tick what applies, and say why for anything left unticked.

  • Every example rebuilds, and git status --short shows only the changes I meant. Not rebuilt: no kit or example changes; the diff is the three files above.
  • No comments in code.
  • Kit changes are opt-in, and every existing example is byte-identical (or this PR says which pages change and why). No kit change.
  • I built and looked at both themes. No visual change.
  • Figures with pipes, cables or round parts: node build.mjs --audit ends audit passed, every failing line at 0. Not applicable.
  • node scripts/lines.mjs prints line ends: 0 on both themes and in every resting pose. Not applicable.
  • Shaders: a slowed contact sheet across every transition shows no pop, and --no-webgl still reads. Not applicable.
  • 3D: a full run ends turn audit passed, and scripts/turn-check.mjs passes. Not applicable.
  • Every number in the figure, the readout, the caption and the docs is true. The numbers above come from the runs described.
  • A line under Unreleased in CHANGELOG.md.

Screenshots

None: no visual change.

🤖 Generated with Claude Code

…nated

A terminated drive run (a test's timeout, Ctrl-C) left its headless
Chrome running; across a parallel node --test those piled up until
every browser test timed out. Chrome now runs in its own process
group, the whole group is killed on every exit, the driver waits for
the group to be gone before it removes the profile folder, and after
a termination it exits by the same signal it received.

- scripts/drive-signal.test.mjs: a terminated run leaves no Chrome and no profile
- CHANGELOG: a line under Unreleased

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant