fix(run): await capped browser close on shutdown so Chromium isn't orphaned - #175
Open
JonasJesus42 wants to merge 1 commit into
Open
fix(run): await capped browser close on shutdown so Chromium isn't orphaned#175JonasJesus42 wants to merge 1 commit into
JonasJesus42 wants to merge 1 commit into
Conversation
…phaned The SIGINT/SIGTERM/timeout `shutdown` handler fired `browser.close()` fire-and-forget and then called `process.exit(130)` synchronously — Node died before the async close completed, orphaning the Chromium subprocess on every Ctrl-C or global-timeout. Orphaned browsers pile up under repeated/ parallel runs and feed the OOM pressure that SIGKILLs siblings (exit 137). Make `shutdown` async and await a capped `browser.close()` (3s race) before exiting. `browser.close()` terminates the subprocess; awaiting it ensures that actually happens. Signal/timeout callers use `void shutdown(...)`. 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
The
shutdownhandler inrunCommand(SIGINT / SIGTERM / global timeout) did:process.exitis synchronous, so Node died before the asyncbrowser.close()ever completed — orphaning the Chromium subprocess on every Ctrl-C or global-timeout shutdown. Under repeated or parallel runs (e.g. inside Conductor) these orphaned browsers accumulate and feed the memory pressure that drives the OS OOM killer to SIGKILL sibling processes (exit 137).Fix
Make
shutdownasync andawaita cappedbrowser.close()(3s race) beforeprocess.exit(130).browser.close()terminates the Chromium subprocess; awaiting it ensures that actually happens, while the cap guarantees a wedged Chromium can't block the exit. Signal and timeout callers invoke it asvoid shutdown(...). The double-signal fast path (hard exit on 2nd Ctrl-C) is preserved.Verification
bun run check(tsc) passes.ps aux | grep -iE "Chromium|headless_shell"— no orphaned processes remain.Part of the memory-pressure / OOM series (see #173, #174).
🤖 Generated with Claude Code
Summary by cubic
Await a capped browser close (3s max) during shutdown so Chromium isn’t orphaned after SIGINT/SIGTERM/global timeout. This stops zombie browsers from piling up and reduces OOM kills during repeated or parallel runs.
browser.close()with a 3s race to avoid blocking on a wedged Chromium.shutdownasynchronously; preserved the fast hard-exit on a second signal.Written for commit b8cb3f3. Summary will update on new commits.