Repository navigation
fix(browser): raise Chrome MCP handshake/navigate timeouts for real npx cold-start cost - #253
Conversation
…px cold-start cost Live-measured on a fleet arm64 canary (arief-openclaw-test, via ENG-20866): `npx -y chrome-devtools-mcp@latest` alone takes 69-73s to start, almost entirely user CPU, before it ever attempts connecting to a --wsEndpoint. The old 30s CHROME_MCP_HANDSHAKE_TIMEOUT_MS guaranteed every remote-CDP attach (e.g. browser-handoff) timed out on npx's own cold-invocation cost alone, never reaching the actual browser connection -- confirmed unrelated to network reachability or CDP-relay auth (curl to the relay endpoint responded in ~6ms). CHROME_MCP_NAVIGATE_TIMEOUT_MS also needed raising: navigateChromeMcpPage threads it into callTool's own options.timeoutMs, which the shared leaseSession -> getSession -> waitForChromeMcpReady path also uses to cap the session-attach wait, not just the per-navigation MCP call -- so a navigate-first attach on a cold session would still cut off early even with the handshake constant alone raised. Updated the two tests hardcoded to the old 20_000/25_001 values. Co-Authored-By: Claude Sonnet 5 <[email protected]>
fast-uri 3.1.6 (transitive via ajv) has two HIGH advisories: GHSA-qw65-cvwx-89v3 and GHSA-58mr-gqgx-xq4g. Matches the fast-uri bump already staged in release PR #252. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Dependency graph guard clearedThis PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh
|
checks-node-core-tooling caught the miss: root and acpx/lobster plugin shrinkwraps still pinned [email protected] after the override bump, failing the pnpm-lock/shrinkwrap alignment test. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This reverts commit 115c37e.
This reverts commit d7b6a57.
…e-mcp-handshake-timeout
There was a problem hiding this comment.
Code Review Summary
Verdict: Approve
Timeout-only change: CHROME_MCP_HANDSHAKE_TIMEOUT_MS 30s -> 120s and CHROME_MCP_NAVIGATE_TIMEOUT_MS 20s -> 130s, grounded in live canary measurements (npx cold-start 69-73s user CPU). Inline comments document why each floor was chosen and the accepted trade-off (hung real navigations take longer to surface).
Looks Good
- Tests updated consistently (navigate timeout arg 130s, safety-net 135s = 130s + 5s buffer)
- Navigate ceiling kept above handshake floor so first-touch navigate doesn't cut off the attach
- No security surface change; constants only
Reviewed by Hermes Agent (backstop sweep)
There was a problem hiding this comment.
Approve covers 21e41893 specifically.
Evidence-backed verifications at head (per repo AGENTS.md review bar: whole module + callers/callees/siblings read, not diff-only):
-
Claim: the navigate timeout doubles as the cold-attach cap. TRUE in code.
navigateChromeMcpPageresolvestimeoutMs ?? CHROME_MCP_NAVIGATE_TIMEOUT_MS(extensions/browser/src/browser/chrome-mcp.ts:1487) and passesresolveChromeMcpNavigateCallTimeoutMs(resolvedTimeoutMs)ascallTool'soptions.timeoutMs(:1499); the grace is +5s viaaddTimerTimeoutGraceMs(packages/normalization-core/src/number-coercion.ts:197), so 130s + 5s = 135s at the call layer.callTool->leaseSession(:1251) ->getSession(..., options.timeoutMs, ...)(:1196-1201) ->waitForChromeMcpReady(session, profileName, timeoutMs, signal)(:1058), where that same timeoutMs racessession.ready(:826-836). Pre-change, a navigate-first cold attach was capped at 25s, tighter than the handshake's own 30s timer. The PR's stated mechanism is exactly what the code does. -
Handshake budget raise is coherent with the navigate raise.
withChromeMcpHandshakeTimeoutracesclient.connect+listToolsagainstCHROME_MCP_HANDSHAKE_TIMEOUT_MS(:724-741, used at:766). 120s sits comfortably above the measured 69-73snpxcold start, and the 135s navigate call-level ceiling stays above the 120s handshake budget it races, so a first-touch navigate no longer cuts the attach off below the handshake allowance. Constants are internally consistent and the new comments document the measured basis and the accepted trade-off. -
Tests updated correctly; claimed 46/46 reproduces locally. The two touched assertions match the code (
chrome-mcp.test.ts:1391expects thenavigate_pagetimeout arg 130_000;:1426advances past the 135s safety net). The spec holds 46it(blocks, matching the claimed count. Local run at head:node scripts/run-vitest.mjs extensions/browser/src/browser/chrome-mcp.test.ts-> Test Files 1 passed, Tests 46 passed (46). Repo-wide grep shows no other suite hardcodes the old constants; the25_000expectations inbrowser-tool.test.tsare the unrelatedtarget=nodeproxy lane (20s proxy + 5s gateway slack,browser-tool.ts:344). -
The deliberately-untouched
DEFAULT_BROWSER_PROXY_TIMEOUT_MS(20s) does not gate the fixed path. It only wraps thetarget=nodebrowser.proxylane (browser-tool.ts:340-343,node-host/invoke-browser.ts:144-146). The browser-handoff attach runs in-process through the extension's own route handlers (routes/agent.snapshot.ts:335callsnavigateChromeMcpPagedirectly;server-context.tab-ops.ts:303callsopenChromeMcpTab), and ENG-20866's observed failure was the 30s "Chrome MCP handshake timed out" error, which could only have surfaced if no 20s proxy wrapper sat on that path. The author's blast-radius reasoning checks out. Residual, matching the PR body's own caveat: atarget=nodenavigate against a node whose profileusesChromeMcpwould cold-attach behind the 20s proxy cap, so that lane may need its own raise later. Non-blocking follow-up, correctly disclosed rather than silently widened. -
Typecheck/lint/CI at head.
pnpm tsgo:extensionsclean; scopedoxlinton both touched files exits 0. All check-runs on21e41893report success (dispatch, checks-node-* shards, check-lint, check-test-types, check-prod-types, check-shrinkwrap, boundary/dependency guards). The two fast-uri commits and their reverts net to zero: the full PR delta vs the merge-base withorigin/boonis exactly these 2 files, +21/-5, and the dependency-graph-guard bot cleared the current SHA. -
Caller-side behavior confirmed beyond the diff.
openChromeMcpTab'snew_pagecall passes nooptions.timeoutMs, so its attach-wait is unbounded at thewaitForChromeMcpReadylayer and governed solely by the (now 120s) handshake timer insidesession.ready(:817-819) — the open-first flow benefits from the same raise with no further change needed.
Non-blocking nits: none.
CI status reported from the check-runs API on the exact reviewed head; local vitest/tsgo/oxlint run in a 21e41893 worktree as stated above.
There was a problem hiding this comment.
REQUEST CHANGES — reviewed exact head 21e4189.
Both timeout layers still stop the reported cold path before npx finishes: the MCP SDK initialize request defaults to 60s, and the browser tool’s implicit existing-session open deadline is 45s, versus the measured 69–73s npx startup. See the two inline findings for call paths and targeted fixes.
Validation: passed 46/46 and passed 71/71 on the exact head. Repeated on a verified synthetic merge of live base ed3e637 + head 21e4189: 46/46 and 71/71 passed. Exact-head Actions workflows/checks were all completed successfully (skips only where GitHub reported skipped). No live browser-handoff retest was performed.
…l cold-start cost boon-hermes-bot flagged that the PR's 120s outer handshake budget doesn't actually protect the measured 69-73s npx cold-start (ENG-20866), because two shorter, independent timeout layers sit in front of and inside it: - client.connect()/listTools() in chrome-mcp.ts were called with no RequestOptions, so the MCP SDK's own DEFAULT_REQUEST_TIMEOUT_MSEC (60_000ms, verified in the installed @modelcontextprotocol/[email protected] source) applied independently of the outer 120s Promise.race and fired first. - browser-tool.ts's existing-session "open" path defaulted to DEFAULT_EXISTING_SESSION_MANAGE_TIMEOUT_MS = 45_000ms with no caller timeoutMs, which client-fetch.ts turns into a real AbortController timer -- aborting the very first browser-handoff "open" on a fresh host before npx even finishes its cold start, regardless of chrome-mcp's internal budget. Fixed both: pass an explicit timeout to connect()/listTools() matching the 120s handshake budget, and raise the existing-session default to 130_000ms (mirroring chrome-mcp.ts's own navigate-timeout margin above the handshake budget). Added regression tests for both (chrome-mcp.test.ts spies on Client.prototype to exercise createRealSession's real handshake without spawning a real npx process; browser-tool.test.ts covers the omitted-timeout default for "open"). Verified each independently via revert-then-fail. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Retrospective re-review — not a formal approvalPR #253 is already merged at Findings that would have blocked pre-merge approval:
Verification: The exact-head Actions |
…263) Root version, 135 plugin manifests synced via scripts/sync-plugin-versions.ts (pnpm plugins:sync), root + 68 extension npm-shrinkwrap.json version fields and openclaw peerDependency ranges bumped, CHANGELOG section for boon.49. Shipping: #246 (tool-result aggregate budget scales with context window instead of a fixed 256k-char cap, so long tool-heavy sessions stop reading their own successful calls as failures and compaction actually fires on real pressure), #253/ENG-20866 (Chrome MCP handshake/navigate timeouts raised for real npx cold-start cost, unblocking browser-handoff live attach), #256/ ENG-20876 (session_id promoted to a real Sentry tag for the per-session reliability dashboard), #260/ENG-20968 (msteams SharePoint/OneDrive download failures surfaced through MediaFailures instead of silently dropped), #261/ ENG-21009 (Sentry node 8.49 -> 10.75.3, clearing ~12 medium Vanta/Inspector findings from its pinned otel/Prisma instrumentation chain), plus undici/ brace-expansion/axios security bumps and markdown-it/dompurify/golang.org/x/net dependency bumps. Base = 2026.6.11-boon.48. Gateway plus @openclaw/slack, @openclaw/msteams and @openclaw/diagnostics-prometheus bumped in lockstep; only @openclaw/msteams source changed in this train (#260), so a fleet-msteams.sh pass is needed on Teams hosts alongside the gateway roll. Co-authored-by: Claude Sonnet 5 <[email protected]>
What Problem This Solves
Every browser-handoff (ENG-17466) live attach on the
arief-openclaw-testcanary was failing with "Chrome MCP handshake timed out" / "browser failed: timed out", even against a fully valid,readyboon-core CDP session (ENG-20866). The pipeline had never completed end-to-end on any site.Why This Change Was Made
Live-measured directly on the canary (arm64 fleet host):
npx -y chrome-devtools-mcp@latest --versionalone — before it ever attempts connecting to a--wsEndpoint— consistently took 69–73 seconds, almost entirely user CPU (not network I/O), reproducible across two separate invocations. The oldCHROME_MCP_HANDSHAKE_TIMEOUT_MS = 30_000guaranteed every remote-CDP attach would time out onnpx's own cold-invocation cost alone, before the subprocess ever got a chance to attempt the actual browser connection.Separately confirmed this is not a network-reachability or CDP-relay-auth issue:
curl --http1.1from the same canary host to the CDP relay endpoint returned a clean response in ~6ms.CHROME_MCP_NAVIGATE_TIMEOUT_MSalso needed raising:navigateChromeMcpPagethreads this value through ascallTool's ownoptions.timeoutMs, which the sharedleaseSession→getSession→waitForChromeMcpReadypath also uses to cap the session-attach wait, not just the per-navigation MCP call itself. So a cold attach triggered by anavigatecall (rather thanopen) would still cut off early even with only the handshake constant raised.Deliberately not touched:
DEFAULT_BROWSER_PROXY_TIMEOUT_MSinextensions/browser/src/node-host/invoke-browser.ts— a fourth, outer timeout layer shared by every generic browser-tool action product-wide (not scoped to browser-handoff). Reasoned this is only an edge-case risk in the normal attach-first flow, and left alone given its much broader blast radius without more certainty.User Impact
Any feature relying on attaching to a remote/external CDP session via the
browserextension's Chrome MCP driver (currently: browser-handoff, ENG-17466) can now actually succeed on hosts wherenpxcold-start is slow, instead of deterministically timing out before ever reaching the target browser. Trade-off: a genuinely hung real page navigation on an already-attached session now takes longer (up to ~135s including grace) to time out and report failure, instead of ~25s.Evidence
arief-openclaw-test) direct measurement:npx -y chrome-devtools-mcp@latest --version→ 69.1s and 72.6s wall-clock across two runs, ~99% user CPU both times.curl -v --http1.1to the CDP relay endpoint from the same host: clean401in ~6ms (rules out network/relay latency as the cause).node scripts/run-vitest.mjs extensions/browser/src/browser/chrome-mcp.test.ts: 46/46 passing after updating the two tests hardcoded to the old timeout values.🤖 Generated with Claude Code
Summary by cubic
Raises the Chrome MCP handshake timeouts so remote-CDP attaches (browser-handoff) can actually succeed, instead of deterministically timing out on
npx's 69–73s cold-start cost before ever reaching the target browser.Covers three independent timeout layers that each would have fired before the real attach completed:
CHROME_MCP_HANDSHAKE_TIMEOUT_MSraised from 30s to 120s, with an explicit matching per-request timeout passed to the MCP SDK'sconnect()andlistTools()calls, which otherwise default to the SDK's own 60s budget (ENG-20866).CHROME_MCP_NAVIGATE_TIMEOUT_MSraised from 20s to 130s, since it also caps the attach-wait for navigate-first cold sessions.DEFAULT_EXISTING_SESSION_MANAGE_TIMEOUT_MSinbrowser-tool.tsraised from 45s to 130s, which otherwise aborts the first handoff "open" on a fresh host before the handshake can finish.Trade-off: a genuinely hung navigation on an already-attached session now takes up to ~135s to time out instead of ~25s.
DEFAULT_BROWSER_PROXY_TIMEOUT_MSininvoke-browser.tswas deliberately left untouched; it may need raising separately for handoff-attached profiles.Tests updated for the new values, with new regression tests for the SDK timeout override and the omitted-timeout default; the full
chrome-mcp.test.tssuite passes (46/46).Written for commit 5322027. Summary will update on new commits.