Repository navigation
fix(browser): retain stderr when Chrome MCP startup fails - #137993
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Prepared and approved source remains The identical real-SDK/synthetic-child regression changed from 2 failures / 2 passes to 4/4 passing; owner/sibling coverage passed 139/139. Redaction, bounded UTF-8 stderr, successful tool calls and child/cache cleanup are verified. Production +2/-2 (net 0); tests +140; docs +3. Exact local regression and changed-gate commands remain in the PR body. New ordinary-flow proof: real Chromium run 33847930752 passed 1/1, zero skips, one scenario attempt at the same head on fresh Blacksmith Testbox. Native registration, MCP attach, screenshots, reconnect, navigation recovery, launcher probes, revocation/version checks and unpairing passed. Existing assertions and 120s/30s deadlines were unchanged. The first manual run 33846819421 omitted existing CI project cache/offline setup and failed npx -y [email protected] --versionnpm config set cache="$HOME/.npm" offline=true --location=projectpnpm test:e2e:browser-extensionTemporary remote All three items from the fresh ClawSweeper review are addressed: P1 independent verification and P2 SDK inspection are complete. Installed package version is 1.30.0; its stdio.js byte-matches the version-pinned published source. Constructor 49-55 creates the PassThrough; start 103-105 pipes child stderr into it; getter 108-119 documents pre-start listeners. stdio.d.ts:66-73 confirms that contract; Client.connect:274-316 initializes and closes on error. Reviewer confidence gap: resolved by that direct maintainer inspection plus real-SDK, exact-head CI and real Chromium proof. No new source repair is needed. With the head unchanged and review fresh, no re-review request or wait for publisher refresh is needed; no GitHub-enforced approval rule is bypassed. Neither the corrected PASS nor the first manual FAIL establishes the cause of the original Chromium CI timeout, or shows that relocating diagnostic capture fixes it. The Chromium test command exited 0. The linked Testbox Actions host job shows |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 3:10 AM ET / 07:10 UTC. ClawSweeper reviewWhat this changesThe browser plugin captures Chrome MCP subprocess stderr before initialization, adds startup and cleanup regression coverage, and documents the diagnostic log. Merge readiness⛔ Blocked before merge - 3 items remain This remains a useful, focused correction absent from fetched main. No introduced correctness or security defect was found in the inspected source; direct dependency-contract verification remains incomplete. Priority: P2 Review scores
Verification
How this fits togetherThe browser plugin uses a Chrome MCP subprocess to connect browser requests to an existing Chrome session. Its session startup owner handles initialization, diagnostic logging, and cleanup when attachment fails. flowchart TD
A[Browser requests] --> B[Shared session startup]
B --> C[Bounded stderr capture]
C --> D[MCP initialization]
D -->|Success| E[Browser operations]
D -->|Failure| F[Redacted diagnostics]
C --> F
F --> G[Cleanup and attach error]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +140, Docs +3. Total +143 across 3 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one bounded, redacted diagnostic flow owned by session creation and shared by persistent and ephemeral attachments, without adding a transport wrapper or changing startup policy. Do we have a high-confidence way to reproduce the issue? Yes, from source: reject initialization after the subprocess emits stderr, and current main's empty reader suppresses the warning. The supplied before/after run corroborates this; this read-only review did not execute tests. Is this the best way to solve the issue? Unclear pending direct SDK-contract verification: within OpenClaw, moving the existing collector into shared session startup is the appropriate repair and avoids a redundant wrapper or catch-only workaround. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 69a0aa25c778. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Extend the real-child fixture from #137993 with quiet and 2 MiB startup stderr cases. Gate the initialize response on the write callback while retaining actual tool-call and EOF/PID cleanup assertions. The runtime fix remains owned by #137993; this change is test-only. Verified an intended pre-drain RED, identical GREEN, 140 owner/sibling tests, all 19 changed checks, and an independent code review.
Extend the real-child fixture from #137993 with quiet and 2 MiB startup stderr cases. Gate the initialize response on the write callback while retaining actual tool-call and EOF/PID cleanup assertions. The runtime fix remains owned by #137993; this change is test-only. Verified an intended pre-drain RED, identical GREEN, 140 owner/sibling tests, all 19 changed checks, and an independent code review.
…#138022) Extend the real-child fixture from openclaw#137993 with quiet and 2 MiB startup stderr cases. Gate the initialize response on the write callback while retaining actual tool-call and EOF/PID cleanup assertions. The runtime fix remains owned by openclaw#137993; this change is test-only. Verified an intended pre-drain RED, identical GREEN, 140 owner/sibling tests, all 19 changed checks, and an independent code review.
What Problem This Solves
Fixes an issue where operators attaching an existing Chrome session could lose the subprocess diagnostic warning when the Chrome MCP initialization handshake failed. The attach error was returned, but startup stderr was missing from the
browser/chrome-mcplogs even when the child emitted it.Why This Change Was Made
Start the existing stderr capture before
Client.connectstarts the subprocess. MCP SDK 1.30.0 creates the piped stderr stream in the transport constructor and explicitly supports listeners before startup; waiting until initialization succeeds skips capture on initialization failure. The browser plugin's session creator owns this ordering, and both persistent and ephemeral sessions share it.This relocates the existing capture and removes its empty placeholder and late attachment. Production LOC: +2/-2, net 0; tests: +140/-0; docs: +3/-0. Capturing only in the catch would still miss draining during startup, and a new transport wrapper is unnecessary.
User Impact
Failed startup can now include the available bounded, redacted stderr tail in the existing warning log. The browser troubleshooting page points operators to that log. The 8192-byte UTF-8 tail, redaction, returned attach error, subprocess cleanup, successful tool behavior, and 30000ms handshake deadline are unchanged.
Evidence
The focused regression uses the real SDK Client and StdioClientTransport with a synthetic Node MCP child through the production lease flow; only logger output is mocked. With identical test source, the original production code produced 2 failures / 2 passes: persistent and ephemeral initialization failures each emitted zero stderr warnings. With capture moved before connect, 4/4 pass, including tool-discovery failure and a successful initialization/list-tools/tool-call control.
Assertions cover warning content, credential and home-path/profile-label redaction, UTF-8 retention, old-prefix eviction, the 8192-byte bound, stdin EOF, child-process exit, and no cached MCP PID. The successful persistent session remains usable until explicitly closed.
Owner and sibling coverage: 139/139 tests in 5 files pass in the original shared-worker order with
--isolate=false --maxWorkers=1. The selected changed gate passes, including 5 doctor-contract tests, production/test typechecks, targeted lint, formatting, boundary guards, and zero runtime import cycles. No build/module/packaging boundary changes are involved.Commands run from the repository root (Node 24.20.0, pnpm 12.1.0):
The first command was run before and after the production correction. An earlier fixture-only home-directory mismatch was corrected before the accepted failing-before run and is excluded from the regression evidence. Fresh independent Codex pre-commit review reports
scoped-cleanat its selected P0 scope with no findings; the maintainer also reviewed the owner boundary, dependency contract, and proof.Exact-head pull-request CI run 33845809427 passed on attempt 1 at
85b84acf4611812cc133a93195b26421f43c3dc6: 80 successful jobs, 16 intentional skips, and no failures. The required openclaw/ci-gate passed. Automatic Chromium UI E2E was skipped by CI classification; the separate exact-head real Chromium run below supplies that coverage.Native review artifacts validated with zero findings.
OPENCLAW_TESTBOX=1 scripts/pr prepare-run 137993passed using exact-head hosted evidence and prepared the same SHA, without a rebase or additional push. Workflow Sanity also passed.CI context: the earlier Chromium bootstrap failure timed out on existing-session
/tabsafter native registration, auto-pairing, and doctor checks passed. Its connection source was also present unchanged in its raw parent and this task's base; the native-review main baselinea550b3f7a1c3611c574f3c073ef2268de74b1a23retains the same ordering. This PR repairs missing diagnostics; it does not establish or fix that timeout's cause, or distinguish npm provisioning from protocol startup. The diagnostic regression uses a synthetic child with the real SDK; the separate real Chromium run verifies the ordinary native/attach flow. Introduction provenance remains unknown; the known extraction carried the ordering forward.Real Chromium proof: corrected CI-setup run 33847930752, on a fresh Blacksmith Testbox lease at the same head, passed 1/1 with zero skips in one scenario attempt. Native registration, MCP attach, labeled screenshots, reconnect, navigation recovery, launcher probes, revocation, version checks, and unpairing passed with the existing assertions and 120s E2E/30s handshake deadlines unchanged. Both synthetic screenshots were inspected and remain local.
The first manual run 33846819421 failed on existing-session
/tabswith the 30s handshake timeout after omitting the existing CI project npm cache/offline setup. It is retained as a non-CI-parity rig failure, not evidence that this patch introduced a regression. The corrected run used the setup already owned by ci.yml:2532-2556, which keeps the warmed cache reachable when MCP filters npm environment settings and Vitest changes HOME:This was temporary remote test provisioning, not a source fix: original
.npmrcbytes were restored, all 20 source hashes and the complete tracked tree matched before setup and after restoration, both owned leases are stopped, and no fixture roots remain. Neither this PASS nor the first manual FAIL establishes the original CI timeout cause or means the diagnostic relocation fixes it.Disposition of all three before-merge items in the fresh ClawSweeper review:
PassThrough; start lines 103-105 pipe child stderr into that same stream; getter lines 108-119 explicitly allow “attach listeners before the start method is invoked.”The Chromium test command exited 0. The linked Testbox Actions host job shows
cancelledafter lease shutdown; itsRun Testboxholding step was cancelled and cleanup steps succeeded. This is the documented Testbox lifecycle result, distinct from the passing test command and the green required CI workflow.