Repository navigation
Browser service: a starved tab costs one timeout, and setup's dispose never attaches a tab (#384) - #404
Merged
Conversation
…, and a setup's dispose never attaches a tab (#384) After a hidden tab's renderer stalls, cua's REPL-host lane timed out two more Emulation.setFocusEmulationEnabled commands than the vendor's. The page clipboard bridge's removal gave each of its three steps a fresh 3 s budget: the first timed out, the host detached the tab, and each later step attached it again (1.5 s on the page guard, then the focus emulation timed out on the rest). The turn's end ran past its 4 s hook deadline, and the next setup's dispose of the previous runtime joined it. Why only cua's host pays: every new kernel calls setup on both hosts, but the vendor's node_repl starts a fresh trusted worker at each js_reset and cell timeout, so its setup has no previous runtime to dispose and the old worker's leftover work dies with it. cua's worker survives resets by design, so setup disposes (probe and outputs in docs/evidence/2026-11-17-384-worker-lifetime). The setup re-run is correct; the fix is in the removal and the dispose: - the removal's steps share one budget, so a starved tab costs one timed-out command and nothing attaches it again; a tab detached earlier whose page answers is still attached once and cleaned; - dispose removes the bridge only from tabs still attached (a new CDP call option, attach: false), within DISPOSE_CLEANUP_MS (1 s), waiting on a removal already under way only within that budget. test/browser-service/starved-tab.test.mjs: a stand-in tab whose renderer never answers. Before: the turn's end sent Runtime.evaluate then two setFocusEmulationEnabled re-attaches (9 s), and a second setup re-attached twice (9 s). After: one command, no attach, 3 s and 1 s. Plugin 0.28.10. Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)
…s-only flag set, for stress runs only (#384, #383) hosted.sh takes PARITY_CHROME_FLAGS=renderer-backgrounding, which launches the harness Chrome with --disable-renderer-backgrounding alone, and refuses it without PARITY_STRESS. Task 94 found that flag alone takes most stressed runs to no CDP timeout: under load Chrome starves a hidden agent tab's renderer on both hosts. A stress run with it separates the download and file-chooser cases' own failures (#383) from that starvation. It hides the product's behaviour, so it is never on the product path or in gate parity-browser, and gate parity-browser-stress keeps no flags: a diagnosis adds it to that gate's run line on its own branch, as with anti-throttling. Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…when the tab is next attached (#384 review) Disposal never attaches a tab, so when Chrome detached a claimed user tab during a turn and the next setup disposed first, the page kept the bridge's override of navigator.clipboard. Ending the debugger session drops the binding's listener and the script, not the JavaScript already run, and the page cannot tell: in Chrome 156 the binding function stays and calling it throws nothing. Its readText waited until a reload. The 1 s disposal budget could strand a slow page the same way. A removal that did not remove the page side (skipped, out of budget, or unanswered) now leaves the installation in its backend's StrandedPageClipboards, which the service keeps across setups by socket path. The next controller to attach the tab, this runtime's or a later one's, removes it in the background, on its own budget with the debugger kept on a timeout, so the attach and its command neither wait nor lose the tab. Disposal stays bounded. Only a tab's own document is recorded, not a frame's. Tests: clipboard-stranded-chrome.test.mjs, in real headless Chrome with the service's CdpController, Clipboard and bridge: install, Chrome detaches, dispose (readText pending), the next runtime attaches, and the page's own navigator.clipboard is back and readText answers. Through the real host, starved-tab.test.mjs: the next runtime's claim and reload remove the stranded side. Both fail with the restore disabled. Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)
…e, so the stranded record stays (#384 review) Runtime.evaluate answers a page script that threw with a successful reply carrying exceptionDetails. The stranded recovery dropped its record on any reply, and the removal itself counted any reply as removed, so a transient page-side failure left the override for good. Both now count exceptionDetails as a failure: the record is kept, or created, and the next attach tries again. An evaluation that finds no matching bridge still evaluates to false without an exception, a successful no-op. Tests: two real-Chrome cases in clipboard-stranded-chrome.test.mjs, with the page's document.querySelectorAll made to throw during the recovery, and during a disposal's removal, then restored. Before: the override stayed (both time out waiting for its removal). After: the next attach removes it and the page's own clipboard is back. Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)
…resh per test Three Chrome launches beside wheel-scroll-chrome's on the loaded hosted runner left that file's Chrome without a DevToolsActivePort in 20 s (run 44222491097). One launch per file, with a navigation between tests to drop what the last one left in the page. Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)
… plugin 0.28.12 The only conflicts were the plugin version in plugin.json and marketplace.json (main 0.28.11, this branch 0.28.10), resolved to 0.28.12. Main's changes (the macOS engine's set_value without focus, the secrets docs and the surface text) touch no file of this branch. Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)
SSFSKIM
added a commit
that referenced
this pull request
Nov 18, 2026
…-field-unread (refs #405) Sminos-Session: cursor235#b93055dd (cua on macbook)
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.
Refs #384. Fixes the cua-only cascade after a hidden tab's renderer stalls. The stall itself is not fixed here: under load Chrome starves a hidden agent tab's renderer on both hosts, so #384 stays open for that.
Mechanism
The investigation (task 94, branch
diag/384-cdp-latency, never merged) found that both parity lanes run cua's browser service, host and extension, and stall the same way. After a stall, though, cua's REPL-host lane timed out two moreEmulation.setFocusEmulationEnabledcommands at about 1.5 s, the second while the browser service'ssetupran. Tracing it here gave this sequence:Runtime.evaluateto that tab. The command times out at 3 s and the host detaches the tab. Both lanes show this one row.GUARD_WAIT_MS), thensetFocusEmulationEnabledtimed out on the 1.5 s that was left. That is ~9 s in all, past the turn-ended hook's 4 s deadline, so the work ran on into the next case.js_resetand fixture-setup cell start a new kernel, and its bootstrap callssetup. Thatsetupdisposes the previous runtime, and the dispose joined the removal still running. This is therpc setuprow in the timeline.Why setup runs again, and why only cua's host pays. Every new kernel calls
setup, on both hosts: each parity case starts withjs_reset, and a cell timeout also starts a new kernel. In the timeline every slowrpc setuprow lies outside every scenario cell, at the next case's start. The re-run is correct behaviour. The difference is the trusted worker's lifetime. The vendor'snode_replstarts a fresh worker at eachjs_resetand each cell timeout, so itssetuphas no previous runtime to dispose, and the old worker's leftover turn-end work dies with it. cua's worker survives resets by design (own-REPL-host spec, Decision Log 2026-10-14), so itssetupdisposes. Proof:docs/evidence/2026-11-17-384-worker-lifetime/holds a probe that drives both hosts with a fixture service reporting its worker's pid. On the vendor host the pid changes after every reset and timeout. On cua's host one pid lasts the whole run.Fix
So, as 791 item 2 asks, only the removal and the dispose change (
src/browser-service/clipboard-bridge.mjs,cdp.mjs):One budget for the removal. The removal's three steps now share one action budget. On a starved tab that costs one timed-out command. The host detaches the tab at that timeout, and the spent budget sends nothing more, so nothing attaches the tab again. A tab detached earlier whose page answers again is still attached once and cleaned, as before.
A dispose that never attaches. Dispose removes the bridge only from tabs still attached, through a new CDP call option,
attach: false. A detached tab fails at once withtab_detached, and "Debugger unattached" is not retried. All of this runs withinDISPOSE_CLEANUP_MS(1 s), and a removal already under way is waited for only within that budget. The backend connection, which closes right after, ends the debugger sessions, and with them the binding and the script.The page is restored later when a removal can't do it now. Disposal never attaches a tab, but the page side of the bridge is JavaScript, and ending the debugger session doesn't undo it. The page can't tell either: in Chrome 156 the binding function stays, and calling it throws nothing. So a removal that didn't remove the page side leaves the installation in its backend's
StrandedPageClipboards. That covers a removal that skipped a detached tab, ran out of its budget, or got no answer from the page. The service keeps this record across setups, keyed by socket path. The next controller to attach that tab, in this runtime or a later one, removes the page side in the background. It uses its own budget and keeps the debugger on a timeout, so the attach and the command behind it neither wait nor lose the tab. (Review finding P2: real headless Chrome showedreadText()pending forever after detach, dispose and reconnect.)A removal now also counts a page script that threw as a failure (fix wave 2, review finding P2).
Runtime.evaluateanswers such a script with a successful reply carryingexceptionDetails, so both the removal and the recovery check for it, and the record is kept or created. An evaluation that finds no matching bridge is still a successful no-op.Limits that remain:
setup. The review measured 3004 ms when a re-attach was already in progress, becausecdp.detachAllTabsjoins an attachment under way. That join is older than this PR. I left it: skipping it could let an attach finish after the connection closes, which would leave Chrome's debugger on a tab the host had already released.A second commit documents
--disable-renderer-backgroundingas a diagnosis-only flag set inscripts/repl-parity/hosted/hosted.sh, as 791 item 3 asks.PARITY_CHROME_FLAGS=renderer-backgroundingis refused withoutPARITY_STRESS. Gateparity-browser-stresskeeps no flags (its default is unchanged), and a diagnosis adds the set to the gate's run line on its own branch, as with anti-throttling. Plugin 0.28.10.Tests
Fix wave 1 (f5e556f) adds
test/browser-service/clipboard-stranded-chrome.test.mjs. It runs in real headless Chrome (skipped without one) with the service's ownCdpController,Clipboardand bridge, over a backend that opens one DevTools WebSocket per attach. The steps: install the bridge, Chrome detaches the tab, dispose (the page'sreadTextis now pending forever), the next runtime attaches. The test then checks that the page's ownnavigator.clipboardis back andreadTextanswers. The wave also adds a real-host case tostarved-tab.test.mjs: the next runtime's claim and reload remove the stranded side. Both fail with the restore disabled (7.1 s and 5.1 s waiting for the removal) and pass with it.test/browser-service/starved-tab.test.mjsruns through the real host and the fake extension. Its stand-in tab's renderer never answers:Runtime.*,setFocusEmulationEnabled,Page.enableand the page guard are held.RED, before the fix. It reproduces the hosted signature exactly:
GREEN, after the fix:
The browser-service suite passes whole. After fix wave 1, with real Chrome on, that is 437 tests: 435 pass and 2 are skipped (the drift checks that need
npm ci). So do the REPL-host tests (208: 192 pass, 16 skipped, platform-gated) andtest/repl-parity/hosted.test.mjs.Under load
The fix was cherry-picked onto the instrumented diag branch (
diag/384-fix-stressat d13190f, never merged). The sameparity-browser-stressand-swapgates as the baseline ran there at cpu:2. The cascade signature countssetFocusEmulationEnabledtimed out at about 1.5 s outside every cell, and slow rows duringrpc setup:rpc setupslow rowsFix runs: 44199386809, 44199387760 and 44203056319, each covering both orders (vendor-first, then cua-first: cua 1/31, 14/19, 15/14; vendor 14/15, 15/15, 15/12).
The cascade is gone. Every stall on cua's lane now ends where the vendor lane's does, with one turn-end
Runtime.evaluateat 3 s. The shared starvation stays, and it is noisy: one cua-first run had a 30 s stall episode inside a case's cells, the same position effect the investigation saw. Every stress run is RED on the #383 download and file-chooser family, on both lanes, as in the baseline.Gates
ci-gate cdfc1200: GREEN, all 9 gates includingparity-browser(https://github.com/SSFSKIM/cua/actions/runs/44199387215).ci-gate edc491d2(fix wave 2): GREEN, all 8 gates (https://github.com/SSFSKIM/cua/actions/runs/44226137983). On 840de2b,wheel-scroll-chrome's Chrome had not started within 20 s while the three real-Chrome launches the stranded-bridge tests then made ran beside it; those tests now share one Chrome.ci-gate f5e556f2(fix wave 1): 8 of 9 gates passed on the first run (https://github.com/SSFSKIM/cua/actions/runs/44213877398),parity-browseramong them. Gatetestfailed once, on an unrelated race intest/linux-engine-diff/ancestry-watch.test.mjs(the watcher's refusal came in its other wording). Its rerun was GREEN (https://github.com/SSFSKIM/cua/actions/runs/44219549391). On the hosted runner's Chrome for Testing the real-Chrome test ran and passed in 8.5 s.Sminos-Session: linux171#3c5ca588 (cua on dc-linux171-1e68)