fix(run): reuse discovery browser instead of leaking it (#167) - #173
Open
JonasJesus42 wants to merge 1 commit into
Open
fix(run): reuse discovery browser instead of leaking it (#167)#173JonasJesus42 wants to merge 1 commit into
JonasJesus42 wants to merge 1 commit into
Conversation
`parity run` called runSelectorDiscoveryPass() and discarded its return value. Since #167 that function keeps the live-validation Chromium OPEN and hands it to the caller for reuse (e2e.ts already consumes it). run.ts ignored it and launched a second browser, leaving the discovery Chromium orphaned for the entire run — a resident process that, alongside the main browser and sibling agents, pushed machines into the OOM killer (exit 137). Capture the returned browser as `discoveryBrowser` and reuse it as the main `browser` (falling back to a fresh launch when null), mirroring e2e.ts. The existing SIGINT/timeout `shutdown` handler and outer `finally` now close it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 29, 2026
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.
Problem
parity runwas leaking a whole Chromium process on every run with auto-selectors enabled.runSelectorDiscoveryPass()was changed in #167 to keep its live-validation Chromium open and hand it back to the caller for reuse (to avoid a second launch that OOMs low-RAM machines).e2e.tsconsumes this correctly. Butrun.tsdiscarded the return value (await runSelectorDiscoveryPass({...})) and then launched a separate browser. Result: the discovery/validation Chromium stayed alive, orphaned, for the entire run — a resident process alongside the main browser.When several
parityruns execute in parallel (e.g. inside Conductor), the extra resident Chromium per run drives total RSS up until the OS OOM killer starts SIGKILL-ing processes (exit 137) — often a sibling process rather than parity itself.Fix
Mirror the
e2e.tspattern inrun.ts:discoveryBrowser.browser(discoveryBrowser ?? await launchBrowser(...)).shutdownhandler and outerfinallyalready closebrowser, so cleanup is covered.Net effect: 1 fewer resident Chromium per
parity run(and one fewer launch → faster).Verification
bun run check(tsc) passes.ps aux | grep -iE "Chromium|headless_shell"during a run — was 2+ resident, now 1; 0 after completion.Part of a series addressing memory pressure / OOM during parity runs. Follow-ups:
safeBodySizebody-buffering, single-browser preflight, HTML trimming.🤖 Generated with Claude Code
Summary by cubic
Reuses the live-validation browser from auto-selector discovery in
parity runinstead of launching a second Chromium. This removes the leaked process per run, cuts memory use, and slightly speeds up runs.discoveryBrowserfromrunSelectorDiscoveryPass()and use it as the mainbrowser(fallback tolaunchBrowserwhen absent).finallycleanup to close the reused browser.Written for commit 67d8cc9. Summary will update on new commits.