Skip to content

fix(browser): raise Chrome MCP handshake/navigate timeouts for real npx cold-start cost - #253

Merged
convyusboy merged 8 commits into
boonfrom
ridho/eng-20866-chrome-mcp-handshake-timeout
Oct 2, 2026
Merged

convyusboy merged 8 commits into
boonfrom
ridho/eng-20866-chrome-mcp-handshake-timeout

Conversation

@convyusboy

@convyusboy convyusboy commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Every browser-handoff (ENG-17466) live attach on the arief-openclaw-test canary was failing with "Chrome MCP handshake timed out" / "browser failed: timed out", even against a fully valid, ready boon-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 --version alone — 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 old CHROME_MCP_HANDSHAKE_TIMEOUT_MS = 30_000 guaranteed every remote-CDP attach would time out on npx'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.1 from the same canary host to the CDP relay endpoint returned a clean response in ~6ms.

CHROME_MCP_NAVIGATE_TIMEOUT_MS also needed raising: navigateChromeMcpPage threads this value through as 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 itself. So a cold attach triggered by a navigate call (rather than open) would still cut off early even with only the handshake constant raised.

Deliberately not touched: DEFAULT_BROWSER_PROXY_TIMEOUT_MS in extensions/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 browser extension's Chrome MCP driver (currently: browser-handoff, ENG-17466) can now actually succeed on hosts where npx cold-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

🤖 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_MS raised from 30s to 120s, with an explicit matching per-request timeout passed to the MCP SDK's connect() and listTools() calls, which otherwise default to the SDK's own 60s budget (ENG-20866).
  • CHROME_MCP_NAVIGATE_TIMEOUT_MS raised from 20s to 130s, since it also caps the attach-wait for navigate-first cold sessions.
  • DEFAULT_EXISTING_SESSION_MANAGE_TIMEOUT_MS in browser-tool.ts raised 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_MS in invoke-browser.ts was 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.ts suite passes (46/46).

Written for commit 5322027. Summary will update on new commits.

Review in cubic

…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]>
@convyusboy
convyusboy requested a review from a team September 29, 2026 12:13
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]>
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Dependency graph guard cleared

This PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh /allow-dependencies-change comment after the guard blocks that new head SHA.

  • Current SHA: 53220279d911fa996836d8b91f2d8392050f549f

convyusboy and others added 3 commits September 29, 2026 21:00
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]>

@boon-hermes-bot boon-hermes-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@boon-hermes-bot boon-hermes-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve covers 21e41893 specifically.

Evidence-backed verifications at head (per repo AGENTS.md review bar: whole module + callers/callees/siblings read, not diff-only):

  1. Claim: the navigate timeout doubles as the cold-attach cap. TRUE in code. navigateChromeMcpPage resolves timeoutMs ?? CHROME_MCP_NAVIGATE_TIMEOUT_MS (extensions/browser/src/browser/chrome-mcp.ts:1487) and passes resolveChromeMcpNavigateCallTimeoutMs(resolvedTimeoutMs) as callTool's options.timeoutMs (:1499); the grace is +5s via addTimerTimeoutGraceMs (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 races session.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.

  2. Handshake budget raise is coherent with the navigate raise. withChromeMcpHandshakeTimeout races client.connect + listTools against CHROME_MCP_HANDSHAKE_TIMEOUT_MS (:724-741, used at :766). 120s sits comfortably above the measured 69-73s npx cold 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.

  3. Tests updated correctly; claimed 46/46 reproduces locally. The two touched assertions match the code (chrome-mcp.test.ts:1391 expects the navigate_page timeout arg 130_000; :1426 advances past the 135s safety net). The spec holds 46 it( 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; the 25_000 expectations in browser-tool.test.ts are the unrelated target=node proxy lane (20s proxy + 5s gateway slack, browser-tool.ts:344).

  4. The deliberately-untouched DEFAULT_BROWSER_PROXY_TIMEOUT_MS (20s) does not gate the fixed path. It only wraps the target=node browser.proxy lane (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:335 calls navigateChromeMcpPage directly; server-context.tab-ops.ts:303 calls openChromeMcpTab), 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: a target=node navigate against a node whose profile usesChromeMcp would 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.

  5. Typecheck/lint/CI at head. pnpm tsgo:extensions clean; scoped oxlint on both touched files exits 0. All check-runs on 21e41893 report 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 with origin/boon is exactly these 2 files, +21/-5, and the dependency-graph-guard bot cleared the current SHA.

  6. Caller-side behavior confirmed beyond the diff. openChromeMcpTab's new_page call passes no options.timeoutMs, so its attach-wait is unbounded at the waitForChromeMcpReady layer and governed solely by the (now 120s) handshake timer inside session.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.

@boon-hermes-bot boon-hermes-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@convyusboy
convyusboy merged commit 3be73f9 into boon Oct 2, 2026
138 of 140 checks passed
@convyusboy
convyusboy deleted the ridho/eng-20866-chrome-mcp-handshake-timeout branch October 2, 2026 15:54
@boon-hermes-bot

Copy link
Copy Markdown

Retrospective re-review — not a formal approval

PR #253 is already merged at 2026-10-02T15:54:22Z (merge commit 3be73f9d18611abd193d53793dd8f7ff2c3a18e0), so I will not post a retroactive APPROVED or REQUEST_CHANGES review. The review records show no APPROVED review on head 53220279d911fa996836d8b91f2d8392050f549f; the approvals I found were on the prior head 21e41893ace41f69710d8a3c82b05d13cb988e9a. Treat the merge without a visible exact-head approval as a retrospective review-gate exception.

Findings that would have blocked pre-merge approval:

  1. First-touch navigate is still capped at 20 seconds. In the merged tree, browser-tool.ts calls the direct browserNavigate route without a timeout; client-actions-core.ts hard-codes timeoutMs: 20000. The target=node path also omits timeoutMs, so invoke-browser.ts uses its 20-second fallback. The server route enters withRouteTabContext before navigateChromeMcpPage (agent.snapshot.ts), so a cold existing-session attach can be cut off before the measured 69–73-second npx startup, regardless of the new 130-second internal navigation timeout. Propagate the existing-session budget through both direct and node navigate paths, or narrow the PR's navigate-first claim.

  2. The MCP SDK still imposes a 60-second deadline on navigate_page. chrome-mcp.ts calls client.callTool without RequestOptions; navigateChromeMcpPage only passes the longer value to the wrapper's local timeout. The pinned SDK is @modelcontextprotocol/[email protected]; its Client.callTool accepts RequestOptions as the third argument, and its RequestOptions.timeout defaults to 60,000 ms. A slow MCP tool call therefore still rejects at the SDK's 60-second deadline before the wrapper's 130-second timer. Pass the longer timeout as the SDK request option for navigation calls and add a regression assertion for that third argument.

Verification: The exact-head Actions CI workflow completed successfully. My focused local invocation did not reach test execution: this sparse checkout omitted internal workspace sources (@openclaw/media-core and @openclaw/model-catalog-core), so I am not claiming those focused tests passed.

convyusboy added a commit that referenced this pull request Oct 2, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants