Repository navigation
fix(browser): drain Chrome MCP stderr before connect, not after - #243
Merged
Merged
Conversation
Live debugging on arief-openclaw-test: the browser tool kept failing with a generic "Chrome MCP handshake timed out" against a browser-handoff CDP profile, with no way to tell why. Direct network checks (curl, boon-core pod logs) ruled out the remote endpoint -- the request never even reached boon-core -- pointing at the local Chrome MCP subprocess itself, but its stderr was never captured to say what actually went wrong. createRealSession only wired up drainStderr(transport) *after* client.connect(transport) resolved successfully -- so the one case this stderr capture exists for (a hung or failing handshake) is exactly the case where it never engages, silently discarding whatever the subprocess itself logged. The MCP SDK's own StdioClientTransport returns its stderr PassThrough immediately from the constructor, specifically so callers can start consuming it before the child process spawns (confirmed against node_modules/@modelcontextprotocol/sdk's stdio.js source and its own stderr getter docstring). Moving the drain call before connect() is safe and means a future handshake timeout/failure will actually show the subprocess's own error instead of a black box. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 1 file
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
cubic review feedback on #243: the comment narrated before/after history and repeated SDK rationale around a one-line call. Reduced to the invariant and failure consequence. Co-Authored-By: Claude Sonnet 5 <[email protected]>
augusteo
approved these changes
Sep 25, 2026
augusteo
left a comment
There was a problem hiding this comment.
Reviewed exact head 21b4aef: no actionable code findings. Moving stderr draining ahead of connect() matches @modelcontextprotocol/sdk 1.29.0, whose piped stderr PassThrough is created before start(). Exact-head CI completed successfully. Local tests were not run; the CI plan excludes the full browser-extension Vitest shard, so the handshake failure path is not directly exercised. No merge or deployment performed.
convyusboy
added a commit
that referenced
this pull request
Sep 28, 2026
…249) * chore(release): bump version 2026.6.11-boon.46 -> 2026.6.11-boon.47 Root version, 135 plugin manifests synced via scripts/sync-plugin-versions.ts, changed npm-shrinkwrap.json files regenerated, CHANGELOG section for boon.47. Shipping: #236/#239 (a plugin tool's own execute() handler can now reliably schedule/unschedule a cron-backed session turn, fixing the browser-handoff recheck across three sequential live-found bugs), #240 (recheck backoff cap tightened 5m -> 2m), #242 (recheck messages the customer before attaching the browser), #241 (delivery.mode: "none" cron jobs can deliver an explicit message-tool send), #243 (Chrome MCP stderr drained before connect, not after), #247 (distinct exec-trajectory label for boon-projects schedule append/list), ENG-20030 (shared turn-resume-instruction wording for boon-core/anychat-boon-web), #248 (Docker build no longer OOMs 8 GB CI runners). Base = 2026.6.11-boon.46. Gateway plus @openclaw/slack, @openclaw/msteams and @openclaw/diagnostics-prometheus bumped in lockstep; no separately published plugin source changed in this train, so a gateway roll delivers all of it. Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(release): regenerate stale extension npm-shrinkwrap.json versions for boon.47 pnpm plugins:sync bumps each plugin's package.json version but does not touch its checked-in npm-shrinkwrap.json, so 65 published extension shrinkwraps still embedded version 2026.6.11-boon.46 despite package.json already reading boon.47. Since npm-shrinkwrap.json ships inside the npm artifact, this would have published every affected plugin with a mismatched embedded version. Bumped the version field(s) in all 65 (plus the openclaw peerDependency range where present) to 2026.6.11-boon.47, matching the pattern boon.46's bump commit already applied to these same files. Co-Authored-By: Claude Sonnet 5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5 <[email protected]>
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.
What Problem This Solves
Live testing of the browser-handoff flow on arief-openclaw-test kept failing with a generic
Chrome MCP existing-session attach failed ... Chrome MCP handshake timed out, with no way to tell what actually went wrong. Direct investigation ruled out the obvious causes:curlWebSocket-upgrade probe from the same host to boon-core's CDP relay endpoint succeeded normally (401 for a bad ref, logged as expected).That means the failure is local to openclaw's own Chrome MCP subprocess, not the remote endpoint — but nothing was capturing that subprocess's own diagnostic output.
Why This Change Was Made
createRealSession(extensions/browser/src/browser/chrome-mcp.ts) only wired upgetStderr = drainStderr(transport)afterclient.connect(transport)resolved successfully:So the one case this stderr capture exists for — a hung or failing MCP handshake — is exactly the case where it never runs, and the
catchblock'sgetStderr()call returns an empty string, discarding whatever the subprocess itself logged about why it never came up.Checked the MCP SDK's own source (
node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js):StdioClientTransport's constructor creates itsstderrPassThroughimmediately whenstderr: "pipe"is passed, and itsstderrgetter's own docstring says it's "returned immediately, allowing callers to start consuming it before the child process is spawned." Draining it right after constructingtransport(before callingconnect()) is exactly the intended, documented use — not a hack.User Impact
No behavior change for the happy path. When a Chrome MCP attach genuinely hangs or fails during the handshake (as currently happening on arief), the resulting error/log will include the subprocess's own stderr output instead of nothing — turning an opaque "handshake timed out" into an actionable diagnostic.
Evidence
curlsucceeded) and boon-core-side involvement (zero log trace across all 3boon-webpods in the exact time window).@modelcontextprotocol/sdk'sStdioClientTransport(constructor +stderrgetter) that draining beforeconnect()is safe and intended.node scripts/run-vitest.mjs extensions/browser/src/browser/chrome-mcp.test.ts— 46/46 passing (single-worker, per this worktree's known fan-out/worker-crash limitation for the full directory —pnpm tsgo:core,check:import-cycles, oxlint, and oxfmt all clean on the changed file).git diff --numstat— 7 insertions / 2 deletions; no test file needed updating (existing tests replacecreateRealSessionentirely viasetChromeMcpSessionFactoryForTest, so none exercise this exact code path — documented in-code instead, matching this file's existing pattern for subtle ordering invariants).🤖 Generated with Claude Code