fix(browse): kill old server before restart to prevent orphaned chromium processes#296
Closed
eternalwaitt wants to merge 1 commit intogarrytan:mainfrom
Closed
Conversation
…ium processes When the health check fails or the server connection drops, `ensureServer()` and `sendCommand()` would call `startServer()` without first killing the previous server process. This left orphaned `chrome-headless-shell` renderer processes running at ~120% CPU each. After several reconnect cycles (e.g. pages that crash during hydration or trigger hard navigations via `window.location.href`), dozens of zombie chromium processes accumulate and exhaust system resources. Fix: call `killServer()` on the stale PID before spawning a new server in both the `ensureServer()` unhealthy path and the `sendCommand()` connection- lost retry path. Fixes garrytan#294
garrytan
added a commit
that referenced
this pull request
Mar 22, 2026
Owner
|
Merged into #325 (wave 1: /cso launch + security hardening). Thank you for the contribution! |
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
When the browse server's health check fails or the connection drops (e.g. pages that crash during hydration or trigger hard navigations via
window.location.href),ensureServer()andsendCommand()callstartServer()without killing the previous server process first.This leaves orphaned
chrome-headless-shellrenderer processes running at ~120% CPU each. After several reconnect cycles, dozens of zombie chromium processes accumulate and exhaust system resources — in my case, 7 processes at ~840% CPU total, which crashed my dev server.Fix
Call
killServer()on the stale PID before spawning a new server in both restart paths:ensureServer()— when the health check failssendCommand()— when the connection is lost (ECONNREFUSED/ECONNRESET)Testing
Simulated a frozen server via
kill -STOP(health check timeout path):Fixes #294