Repository navigation
Conversation
…() through it rejectAllAndMarkDead now unpublishes and kills the browser process it was bound to, for both the CDP transport and the WebKit host client. A dead transport never leaves a published process behind, so the next new Bun.WebView() spawns at once instead of failing with "Failed to spawn Chrome" until the old process has been reaped. The isolation hook shrinks to rejectAllAndMarkDead plus clearing the cached global. WebView.closeAll() goes through the same path: every view closes, its pending promises reject with "WebView closed by WebView.closeAll()", and the browser dies. Before, closeAll() only sent SIGKILL; a WebView created in the same tick bound to the dying transport, and one created later threw until the reap. The tests that carried reap-retry loops for this lose them. The constructor refuses to create a view on a global whose active DOM objects are stopped, so a rejection handler that runs while bun test --isolate retires a file cannot bind a new browser to the dying global. The WebSocket transport mode gets the --isolate test the pipe mode already had, against a mock CDP endpoint that now lives in mock-cdp.ts.
|
Warning Review limit reachedYour included review limit has been reached. You’re in a promotional period — use the checkbox below to run this review for free:
On-demand reviews are free for the next 28 days. After that, they cost $0.25 per reviewed file. How can I continue?Run this review now using the option above, or comment You can also wait for the limit to reset (next review available in 14 minutes), then comment An organization admin can change what happens after included review limits in Billing. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (14)
Comment |
|
Status: implemented, waiting on CI. Reproduction on main (fake browser from |
|
Updated 12:57 AM PT - Aug 23rd, 2026
❌ @robobun, your commit e76868a has 2 failures in
🧪 To try this PR locally: bunx bun-pr 40176That installs a local version of the PR into your bun-40176 --bun |
|
Closing as stale: this PR conflicts with main, and its last commit is from 2026-08-23. The branch stays, so the work is not lost. To pick it up again, rebase the branch on main and reopen this PR. |
Follow-up to #40165.
Problem
WebView.closeAll()only sentSIGKILL. Anew Bun.WebView()in the same tick bound to the dying transport, and a later one threw "Failed to spawn Chrome" until the old process was reaped (Bun__Chrome__ensurerefuses to spawn while a process is published). The docs promise "respawn as needed". Three tests carried reap-retry loops for this.bun test --isolatefor the pipe transport only. The WebSocket mode had no test.Fix
rejectAllAndMarkDeadcallsBun__Chrome__retire()/Bun__WebViewHost__retire(): a dead transport never leaves a published browser behind. The adopt-failure branches retire too, and the spawn entry points assert in debug builds that nothing is published.retireGlobalshrinks torejectAllAndMarkDeadplus clearing the cached global.WebView.closeAll()goes throughrejectAllAndMarkDead("WebView closed by WebView.closeAll()")on both backends and throwsERR_INVALID_STATEoff the main thread. Over WebSocket it used to be a no-op (no process to kill); it now closes the connection and the views. Process exit stays kill-only.ERR_INVALID_STATEonce the global's active DOM objects are stopped, so a handler that runs while--isolateretires a file cannot bind a new browser to the dying global.webview-chrome-pipe.test.ts(newcloseAll()case and the late-creation check fail on main),webview-chrome-disconnect.test.ts(new WebSocketcloseAll()and--isolatecases on the mock CDP server, now inmock-cdp.ts), the real-Chrome suite with its new Worker case.Background
Transportand the WebKitHostClientare process singletons, each bound to one published browser process (INSTANCEin ChromeProcess.rs / HostProcess.rs) and to the global that spawned it.rejectAllAndMarkDeadis where a transport dies: it closes the connection, rejects every pending promise and marks the views closed. Every loss path ends there.Bun__Chrome__retire(webview: retire the transport with its global under bun test --isolate #40165) unpublishes and kills the process and marks it retired, soon_exitonly reaps it.Notes
Fail-before with main's
src/:closeAll() rejects what is pending and the next WebView spawns at oncefails (the next view binds to the dying transport or throws), the--isolatecase fails onlate: "created"instead ofERR_INVALID_STATE, and the real-ChromecloseAll()disconnect case rejects with "Chrome killed by signal 9" instead of the new message. The WebSocket--isolatecase passes on main as well: it documents what #40165 fixed in that mode, which no test exercised.closeAll()on a transport that never spawned anything marks it dead with no published process to retire. The next constructor resets it and spawns. The fake browser inwebview-chrome-pipe.test.tstakes--exit-delay=20000in thecloseAll()case, so the same-tick spawn only works ifcloseAll()unpublished the old process itself.Once
INSTANCElets go of a retired process, only its exit handler references it. When bun exits before the exit is reaped, LeakSanitizer on the ASAN lane reported theProcessand itsChromeProcessbox as leaks (the same memory was live before, but reachable throughINSTANCE). Retired processes now hang off a staticRETIREDlist untilon_exitfrees them.Real Chrome here runs through a
--no-sandboxwrapper inBUN_CHROME_PATH(this container is root): all 5 files intest/js/bun/webview/, 77 pass, 59 skip (WebKit), 6 todo.no test proof · iteration 0 · platform-specific test(s) that do not run on this machine, deferring to CI, which covers all platforms: test/js/bun/webview/webview.test.ts, test/js/bun/webview/webview-chrome.test.ts, test/js/bun/webview/webview-chrome-pipe.test.ts, test/js/bun/webview/webview-chrome-disconnect.test.ts