Repository navigation
fix(engine): wait briefly for Chrome's exit status before reporting a lost render page - #8928
Conversation
… lost render page
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 23712c0. No blocker.
What I read: the full diff, openPage.ts in full, the new tests and the existing test helpers at the top of openPage.test.ts. Not read: the callers that catch PageTabLostError. Read only, nothing run locally; checks were still running when I posted.
What I checked:
- The wait runs only on the failure path (no page and the browser disconnected), so a healthy open is not delayed, and it is bounded at 500 ms with an unref'd timer.
- The
exitlistener is removed on both the exit and the timeout paths, and the timer is cleared on exit; the tests assert a zero listener count in all three cases. - A process that already has a code or signal, a missing process, and a process object without listener methods all return at once, so the existing stubs and a remote browser keep the old message.
PageTabLostErroris constructed in one place only, so the optional second argument changes no other caller.- The body has the
fails without the fix:line and both named tests exist at this head.
Non-blocking note: the first new test depends on a real child exiting within 500 ms of its stdin closing. That should hold comfortably, but it is the one timing-dependent test in the file if a loaded runner ever flakes here.
Need: yes · Size: fits (+132 −4) · Reuse: n/a · Simpler: no · Structure: fine
Risk: low; at most 500 ms added to an already failing open.
— Rames
Edit accuracy: accurate 273 (base branch 271), smooth 84 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
Summary
When Chrome exits while
openPage()is opening a render page, the CDP connection often closes before Node'schild_processemits itsexitevent and populateschild.exitCode/child.signalCode. Readingchild?.exitCodesynchronously producedChrome exited while opening a render page (exit code unknown, signal none)instead of the real exit code or signal.packages/engine/src/services/openPage.ts: when!browser.connectedafternewLivePage()fails, wait up to 500 ms (.unref()timer, listener always removed) for the child processexitevent before constructingPageTabLostError. If the process already exited or exposes noEventEmittermethods, return immediately.packages/engine/src/services/openPage.test.ts: cover a real spawned child process exiting shortly after disconnect, a delayed signal exit, and a hung process hitting the wait bound with no leakedexitlistener.Test plan
"waits briefly for a real Chrome child process to finish exiting so its exit code is reported"and"reports a delayed signal exit and cleans up its exit listener when Chrome hangs"inpackages/engine/src/services/openPage.test.ts(both fail onorigin/mainwithexit code unknown, signal none).packages/engine/src/services/openPage.test.ts: 6 passed, 0 skipped (3 consecutive runs).packages/engine/src/services/frameCapture-pageTabLost.test.ts: 3 passed, 0 skipped.oxlint,oxfmt --check, andpackages/enginetsc --noEmit: 0 warnings, 0 errors.