Repository navigation
fix(drive): stop Chrome and its helpers when the run ends or is terminated - #147
Open
jacoblewisau wants to merge 1 commit into
Open
jacoblewisau wants to merge 1 commit into
jacoblewisau wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
scripts/drive.mjsstops Chrome and all of its helper processes together: Chrome is spawned in its own process group, oneSIGKILLtakes 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 longwaitaction, sendsSIGTERMonce Chrome is running, then asserts that the driver died bySIGTERM, 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-journaland 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.
git status --shortshows only the changes I meant. Not rebuilt: no kit or example changes; the diff is the three files above.node build.mjs --auditendsaudit passed, every failing line at 0. Not applicable.node scripts/lines.mjsprintsline ends: 0on both themes and in every resting pose. Not applicable.--no-webglstill reads. Not applicable.turn audit passed, andscripts/turn-check.mjspasses. Not applicable.UnreleasedinCHANGELOG.md.Screenshots
None: no visual change.
🤖 Generated with Claude Code