Skip to content

feat(browser): reuse admitted browser-socket transport and allow discovery_timeout_ms - #9203

Merged
morluto merged 11 commits into
morluto:mainfrom
saariuslystoned:feat/cdp-browser-socket-reuse-and-deadline
Nov 8, 2026
Merged

morluto merged 11 commits into
morluto:mainfrom
saariuslystoned:feat/cdp-browser-socket-reuse-and-deadline

Conversation

@saariuslystoned

@saariuslystoned saariuslystoned commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Reuse an admitted, healthy loopback browser-socket CDP transport (ws://127.0.0.1:<port>/devtools/browser/<id> / ws://[::1]:<port>/devtools/browser/<id>) across passive browser operations on the same CdpBrowserProvider instance, and add optional per-call discovery_timeout_ms (--discovery-timeout-ms, default 10000 ms) across the six passive browser tools so operators have configurable headroom when approving browser-level consent prompts.

Problem and expected behavior

On Chrome 136+ using chrome://inspect/#remote-debugging (DevToolsActivePort) without /json/version HTTP discovery:

  1. Every passive browser operation (list_browser_targets, inspect_web_page, analyze_web_bundle, observe_web_session, discover_webmcp_tools, capture_web_screenshot) previously opened a brand-new WebSocket connection to ws://127.0.0.1:<port>/devtools/browser/<id> and closed it when that single call finished. In Chrome 136+, each new browser-level WebSocket upgrade triggers a fresh modal "Allow remote debugging?" consent prompt, turning a multi-step MCP session into repeated modal prompts.
  2. CDP discovery previously had no runtime deadline override (CDP_DISCOVERY_RESPONSE_TIMEOUT_MS = 10_000), so human operators reading and approving Chrome's modal consent dialog could exceed the discovery deadline with no caller parameter to extend it.

Expected behavior:

  • Within a live CdpBrowserProvider (such as an active MCP server session), once a direct browser_websocket endpoint completes handshake and discovery (Browser.getVersion, Target.getTargets), retain and reuse that healthy browser WebSocket keyed by exact normalized URL across subsequent calls.
  • Keep per-operation flattened target sessions isolated: each target operation still disables enabled domains and confirms Target.detachFromTarget on completion, evicting and closing the shared browser socket if detachment is unconfirmed or the transport drops/fails, and deterministically closing retained sockets on CdpBrowserProvider.close().
  • Expose optional discovery_timeout_ms (1..2147483647, default 10000 when omitted) on the six passive browser tools and CLI commands, record explicit selections in Evidence parameters while keeping omitted defaults absent, and name discovery_timeout_ms / --discovery-timeout-ms in timeout recovery only on operations that accept it.

Change and scope

Follow the contribution scope.

  • Reusable browser-socket lease (CdpConnection, CdpTargetSessionOwner, CdpTargetSession, CdpBrowserProvider):
    • Factor CdpConnection over an internal CdpTransportCore with withOperation(operation, commandTimeoutMs) so sequential or concurrent operations sharing one browser WebSocket isolate their operation identity, command_timeout_ms, and pending command tracking while sharing transportRoot cleanup ownership.
    • Add acquireBrowserSocket, admitBrowserSocket, releaseBrowserSocket, and evictBrowserSocket on CdpTargetSessionOwner, coalescing concurrent cold-start acquireBrowserSocket calls on the same normalized URL onto one shared in-flight WebSocket handshake (aborting the handshake only if all waiting callers abort). Retain only direct browser_websocket endpoints that complete discovery; keep HTTP /json/version (http_discovery) per-call open/close behavior unchanged, and keep PlaywrightScenarioServiceWorkers single-shot ownership unchanged.
    • Return detachment confirmation from cleanupCdpTargetCommands: if Target.detachFromTarget fails (other than an already-detached session rejection) or times out, or if Target.attachToTarget fails after being sent, immediately evict and close the browser WebSocket (even when a concurrent operation holds a shared lease) so transport close remains the definitive target-session boundary, whereas a caller's own pre-attach discovery deadline or cancellation releases only its lease when transport state remains clean; also evict/close idle retained sockets on fatal protocol errors as well as disconnects.
  • Configurable discovery deadline (browserDeadline.ts, passive browser schemas, CLI, CdpEndpoint.ts, BrowserEvidence.ts, docs/guides/web/browser-observation.md):
    • Add browserDiscoveryTimeoutSchema, selectedCdpDiscoveryTimeoutMs, cdpDiscoveryTimeoutIsSelectable, and cdpDiscoveryTimeoutRecovery in src/domain/browserDeadline.ts (wrapped with cliDecimalField on CLI --discovery-timeout-ms), keeping CDP_DISCOVERY_RESPONSE_TIMEOUT_MS = 10_000 as the default and clamping handshake timer headroom at MAX_BROWSER_DEADLINE_MS (2147483647) so maximum deadlines never overflow Node's 32-bit timer range.
    • Wire discovery_timeout_ms / --discovery-timeout-ms through list_browser_targets, inspect_web_page, analyze_web_bundle, observe_web_session, discover_webmcp_tools, and capture_web_screenshot, without advertising discovery_timeout_ms on non-passive CDP callers (observe_web_execution, inspect_web_event_listeners, Electron, or scenario capture).

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/browserDeadline.ts and passive browser input schemas (src/domain/browserObservation.ts, src/domain/browserSession.ts, src/domain/webMcpDiscovery.ts, src/domain/webScreenshot.ts) own discovery_timeout_ms; src/browser/CdpTargetSessionOwner.ts, src/browser/CdpTargetSession.ts, src/browser/CdpConnection.ts, and src/browser/CdpBrowserProvider.ts own browser-socket transport retention, per-call operation scoping, detachment verification, and provider shutdown cleanup.
  • Contribution scope fit and linked maintainer decision: not applicable (passive loopback CDP transport lifecycle and caller deadline control within the existing CdpBrowserProvider boundary; no new target execution, injection, or mutation).
  • CLI and MCP/tool-catalog contract: list_browser_targets, inspect_web_page, analyze_web_bundle, observe_web_session, discover_webmcp_tools, and capture_web_screenshot accept optional discovery_timeout_ms (1..2147483647, omitted default 10000); corresponding CLI commands accept --discovery-timeout-ms. Both default and compact MCP input schema profiles remain within budget.
  • Provider, bridge, target-format, or platform compatibility: loopback Chromium CDP browser_websocket endpoints reuse an admitted socket across calls on the same CdpBrowserProvider instance; http_discovery endpoints and direct page sockets retain existing per-call connection behavior. One-shot CLI invocations close their provider at command exit.
  • Evidence, artifact, provenance, or reconstruction contract: createBrowserEvidence records discovery_timeout_ms in parameters only when explicitly supplied and omits it when left at the default; browser-socket URLs remain redacted as ws://127.0.0.1:<port>/devtools/browser/[REDACTED].
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): target origin authorization and flattened sessionId attachment/detachment run on every call; unconfirmed Target.detachFromTarget or failed Target.attachToTarget evicts and closes the browser WebSocket; CdpBrowserProvider.close() closes retained idle sockets after active operations settle and preserves AnalysisCleanupLease retry semantics.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none committed; npm run metadata:check, npm run mcp-catalog:check, and npm run docs:check pass cleanly.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated (executed):
    • tests/boundary/browser/cdpBrowserProvider.browserSocket.test.ts and src/domain/browserObservation.test.ts: verify sequential listTargets -> inspectPage -> captureScreenshot over ws://127.0.0.1:<port>/devtools/browser/fake perform a single WebSocket upgrade (openedConnectionCount === 1), normalize scheme case, uncompressed IPv6 loopback spellings, and leading port zeros onto one reuse key while keeping 127.0.0.1 and [::1] separate sockets, coalesce concurrent cold-start calls onto a single WebSocket handshake (keeping the handshake alive for longer-deadline peers when a short-deadline waiter times out), keep an admitted shared socket alive for concurrent peers when one caller hits discovery_timeout_ms or cancels during pre-attach discovery, send Target.detachFromTarget per target call, retain the socket across missing-target authorization errors, evict and reconnect cleanly when the server drops or sends malformed protocol frames on an idle browser socket (preserving pending cleanup lease failure if close fails), immediately close the shared socket when Target.detachFromTarget fails even alongside a concurrent active observeSession (or surface cleanupIncomplete bound to the socket lease if forced close fails), retain AnalysisCleanupLease ownership on finish() callback rejection, preserve per-call command_timeout_ms and operation identity after list_browser_targets, and release the socket on provider.close().
    • tests/boundary/browser/cdpTargetDeadlines.test.ts: verifies custom discovery_timeout_ms governs both browser-socket discovery (Target.getTargets stall) and HTTP discovery (/json/version stall) independently of command_timeout_ms, clamps handshake timers at MAX_BROWSER_DEADLINE_MS (2147483647) without 32-bit timer overflow, and projects provider_timeout with --discovery-timeout-ms remediation.
    • src/domain/webDeadlineControls.test.ts and tests/boundary/browser/webDeadlineBehavior.test.ts: verify schema bounds (1..2147483647), selectable vs non-selectable discovery timeout remediation text, and explicit-only Evidence parameters.discovery_timeout_ms recording.
    • tests/boundary/mcp/browserMcp.test.ts: verifies end-to-end MCP list_browser_targets (with discovery_timeout_ms) followed by inspect_web_page over a browser WebSocket reuses one WebSocket connection across both full and compact MCP profiles while redacting the socket path.
  • Base reproduction or other evidence: executed against the wire-level FakeCdpBrowser HTTP/WebSocket fixture (openedConnectionCount() previously incremented per call on browserWebSocketUrl, and listBrowserTargetsInputSchema rejected discovery_timeout_ms).
  • User-visible CLI/MCP output (if applicable): discovery timeouts on passive browser tools now report CDP browser-socket discovery exceeded its <N> ms discovery_timeout_ms deadline (deadlineExpired) (or CDP discovery response exceeded...) with remediation naming discovery_timeout_ms and --discovery-timeout-ms, while keeping byte budgets explicitly marked as having no runtime override.
  • Remaining proof gaps: verified wire-level loopback WebSocket/HTTP behavior and live headless Google Chrome 156.0.8078.80 DevToolsActivePort single-TCP-socket reuse across sequential MCP operations (lsof-confirmed); manual desktop GUI interaction with Chrome's headed "Allow remote debugging?" modal dialog remains human UI verification.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run src/browser/*.test.ts src/domain/webDeadlineControls.test.ts tests/boundary/browser/*.test.ts tests/boundary/mcp/browserMcp.test.ts tests/boundary/mcp/compactInputSchemaMcp.test.ts tests/boundary/mcp/webBundleContainmentMcp.test.ts tests/boundary/cli/browserCli.test.ts — passed (136 passed | 1 skipped test files, 2281 passed | 6 skipped tests).
  • npx vitest run tests/boundary/browser/cdpBrowserProvider.browserSocket.test.ts tests/boundary/browser/cdpTargetSessionOwner.test.ts — passed (20 passed + 7 passed = 27 passed tests, including distinct per-attachment sessionId isolation and unhandledRejection-free cold-handshake cleanup failure handling).
  • npx vitest run tests/boundary/cli/cliDecimalArguments.test.ts — passed (1 passed test across all registered CLI numeric options).
  • npx vitest run tests/boundary/browser/cdpTargetDeadlines.test.ts — passed (25 passed tests).
  • npm run check:fast — passed (typecheck and lint succeeded, 0 errors).
  • npx oxfmt . && npx oxfmt --check . — passed (All matched files use the correct format).
  • npm run verify:architecture-guards — passed (Architecture guards passed across 2519 source files).
  • npm run verify:test-discovery — passed (Discovered all 3157 test files exactly once).
  • npm run scan:todos — passed (No tech-debt markers found).
  • npm run jscpd — passed (0 threshold violations).
  • npm run knip && npm run knip:production — passed (Knip found no issues).
  • npm run lint:typed — passed (6585 files, 0 errors).
  • npm run metadata:check && npm run mcp-catalog:check && npm run docs:check — passed (6/6 tasks + tests/conformance/readmeConsistency.test.ts 9/9 passed).
  • Trial merge with main (08637b0c2) + multi-Node matrix (v22.23.4, v24.22.2, v26.13.0): clean merge (0 conflicts), npm run check:fast passed, and all 8 changed/focused test files (93/93 tests) passed across Node v22.23.4, v24.22.2, and v26.13.0.
  • Live Google Chrome 156.0.8078.80 DevToolsActivePort + rea mcp socket-reuse verification (v24.22.2): sequential list_browser_targets -> inspect_web_page (WS://127.0.0.1:052525/... normalized) -> capture_web_screenshot (discovery_timeout_ms: 15000) -> update_analysis_settings -> list_browser_targets reused a single OS TCP connection (lsof-verified), confirmed per-call target detachment (attached: false), and redacted the browser socket path ([REDACTED]).

Compatibility, safety, and release

  • Breaking changes or migration steps: none. discovery_timeout_ms is optional and defaults to the existing 10000 ms deadline; callers of CdpBrowserProvider continue to call await provider.close() as already required for bundle-analyzer and transport cleanup.
  • Real Hopper/Ghidra, browser, or OS coverage: verified on macOS arm64 across Node v22.23.4, v24.22.2, and v26.13.0 against wire-level loopback fixtures and live Google Chrome 156.0.8078.80 (--remote-debugging-port=0 DevToolsActivePort browser WebSocket); headed desktop modal consent click remains manual UI verification.
  • Package or release metadata impact: none (metadata:check, mcp-catalog:check, and docs:check pass without tracked metadata diffs).
  • Security, privacy, process, or containment review: browser-socket secret path tokens remain redacted in Evidence ([REDACTED]), origin authorization runs per operation, fixed 8 MiB HTTP discovery and 64 MiB WebSocket message byte caps remain non-overridable, and unconfirmed session detachment closes REA's WebSocket rather than reusing an ambiguous session state.

Author readiness

Human owner: @saariuslystoned

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

The PR retains healthy browser sockets across passive calls and adds optional discovery_timeout_ms controls.

  • Passive browser calls reuse a healthy browser socket within one provider.
  • Passive browser tools let callers set a separate discovery deadline.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Passive browser call] --> B[Normalize endpoint URL]
  B --> C{Healthy socket available?}
  C -->|Yes| D[Lease shared socket]
  C -->|No| E[Share one pending handshake]
  E --> D
  D --> F[Discover and authorize target]
  F --> G[Attach separate target session]
  G --> H[Run operation]
  H --> I{Detach confirmed?}
  I -->|Yes| J[Release lease and retain socket]
  I -->|No| K[Evict and close socket]
  J --> L[Provider shutdown closes retained sockets]
Loading

Reviews (10) · Last reviewed commit: "test(browser): verify distinct browser s..." · Reviewed by Greptile

Comment thread src/browser/CdpTargetSessionOwner.ts Resolved
Comment thread src/browser/CdpTargetSessionOwner.ts Resolved
Comment thread src/domain/browserDeadline.ts Resolved
Comment thread src/browser/CdpTargetSessionOwner.ts Resolved
Comment thread src/browser/CdpTargetSessionOwner.ts Resolved
@saariuslystoned
saariuslystoned marked this pull request as ready for review November 7, 2026 01:03
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-07T01:03:44.514439Z
We couldn’t complete this review. Comment @codex review to try again.
381ac9a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@CassieFox23 CassieFox23 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TL;DR: This is a code read. I ran nothing from the PR, and CI has not run on this head yet. The socket cleanup fixes look right to me. The rebase needs one extra change, and I have one design question about shared sockets.

Edit (7 Nov): I ran this PR at head 3abe2e1 in a VM, and the results are here.

I read the PR head 0494d14 against its merge base 48f5f30. Main is now 99db80a.

Worth a look

  1. The rebase needs the new decimal wrapper. The conflict is with 99db80a (#9178), which touched the same three files: src/cli/browserAdvancedCommands.ts, src/cli/browserCommands.ts and src/cliObservationOptions.ts. That commit wraps every number option in cliDecimalField, so 0x10 and 1e3 are refused. The new discoveryTimeoutMs: browserDiscoveryTimeoutSchema (head cliObservationOptions.ts line 46) has no wrapper. Its schema is a plain z.number() from optionalBrowserDeadlineMs (main browserDeadline.ts lines 21 to 28). Main's tests/boundary/cli/cliDecimalArguments.test.ts checks the number options of every registered command (line 78). So I expect it to flag --discovery-timeout-ms after the rebase. Main's own line is the model: commandTimeoutMs: cliDecimalField(webRuntimeCommandTimeoutSchema) (main cliObservationOptions.ts line 25).

  2. One call's failure closes the socket for everyone. evictBrowserSocket passes a cleanup that returns false (CdpTargetSessionOwner.ts line 227). Then releaseBrowserSocket closes the socket at once, even while other calls hold it (lines 196 to 209). Eviction runs when discovery fails on a reused socket (CdpTargetSession.ts lines 134 to 141, then failCdpOpenAfterCleanup at line 219). It also runs after an attach attempt (CdpBrowserProvider.ts lines 499 to 501). Closing is the safe move when attach state is unknown. But a discovery timeout is different. One caller's short discovery_timeout_ms then ends every call on that browser. Is that on purpose? If so, a line in the tool text would help.

Nit

  • Two calls that start together each open their own socket. acquireBrowserSocket does not share a connect that is still in flight (lines 88 to 125), and admitBrowserSocket then evicts the second socket (lines 142 to 154). So a cold start with parallel calls still shows two Chrome prompts. A pending connect per URL would avoid that.

Looks good

  • Failed cleanup blocks new calls. acquireBrowserSocket retries pending failures first (line 82). It reuses a socket only when failure is unset (line 93).
  • A detach that fails closes the socket. releaseBrowserSocket keeps the socket only when the cleanup returns true, and closes it otherwise (lines 188 to 209).
  • Events stay apart. Each passive tool's listener skips events from any other session. See CdpPageCapture.ts line 83, CdpScreenshot.ts line 101, CdpWebMcpDiscovery.ts line 100 and CdpObservationSession.ts line 115. So a shared socket does not mix their events.
  • Defaults hold. If discovery_timeout_ms is left out, it stays out of Evidence parameters (BrowserEvidence.ts line 168). So old calls keep their evidence ids.
  • Reuse is opt-in. Only two call sites pass reuseBrowserSocket: true (CdpBrowserProvider.ts lines 153 and 434).

Not run

  • No build, no typecheck, no tests. The decimal test result after the rebase is my reading of the code, not a run.
  • I did not check how the reuse key is normalized, so I can't say whether 127.0.0.1 and [::1] spellings of one browser share a socket.
  • I did not test against a real Chrome 136+ consent prompt.

🤖 Written with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

…cket-reuse-and-deadline

# Conflicts:
#	src/cli/browserAdvancedCommands.ts
#	src/cliObservationOptions.ts
Comment thread src/browser/CdpTargetSessionOwner.ts Resolved
Comment thread src/browser/CdpTargetSessionOwner.ts Resolved
@CassieFox23

CassieFox23 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: At 3abe2e1, all three points from my review above look addressed. The 7 test files pass on Node 22, 24 and 26. CI has not run on this head yet.

Edit (7 Nov): I ran this PR again at head 96685a1 in a VM, and the results are here. They cover the reuse-key spelling; a real Chrome 136+ and a merge with the current main are still not run.

Thanks, saariuslystoned, for all three of the fixes you made.

Results

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
The 7 test files (80 tests) 80 passed 80 passed 80 passed
--discovery-timeout-ms 0x10 not run refused, exit 1 not run
--discovery-timeout-ms 1e2 not run refused, exit 1 not run
--discovery-timeout-ms 16 not run accepted, then failed at the connection, exit 1 not run

Six files are the PR's changed tests. The seventh is main's cliDecimalArguments test.

Nothing listens on port 9. So 16 got past argument parsing and failed at the connection. That is expected.

My three points

  • Decimal wrapper. It is now at cliObservationOptions.ts line 34: discoveryTimeoutMs: cliDecimalField(browserDiscoveryTimeoutSchema),. 0x10 and 1e2 are refused. Main's cliDecimalArguments test came in with 99db80a (fix(cli): reject non-decimal integer tokens on every numeric option #9178). It passes in the PR tree.
  • One call's failure closing the socket for everyone. The test at line 783 of cdpBrowserProvider.browserSocket.test.ts passes. It is the PR's own test with a fake browser. It is not a real Chrome.
  • Cold connects. The tests at lines 891 and 952 of the same file pass. Same caveat: fake browser, not a real Chrome.

Not run

  • A real Chrome 136+ consent prompt.
  • A merge with current main. I tested the head as it is.
  • The reuse-key spelling question from my review above.
Test setup
  • Box: Fedora 44 VM, Linux 7.2.11, on my Nobara 44 PC
  • CPU: 4 vCPUs
  • RAM: 8 GB
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 3abe2e1 / 99db80a (merge base with main)
  • Other: VM reverted to clean-6.8.0 before the run. CI, CodeQL and PR title are waiting for a maintainer (action_required).
Commands
Command Node Exit Wall
npm ci --offline 24.22.1 0 18 s
npm run prepare 24.22.1 0 1 s
npm run test:prepare 24.22.1 0 12 s
xvfb-run -a npm run test:focused -- <the 7 test files> 24.22.1 0 27 s
same command 22.23.4 0 27 s
same command 26.12.1 0 24 s
node scripts/rea.mjs list-browser-targets http://127.0.0.1:9 --format json, with --discovery-timeout-ms set to 0x10, 1e2 and 16 (scratch script, guest only) 24.22.1 0 4 s

The scratch script exited 0. The three --discovery-timeout-ms runs exited 1, 1 and 1.

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@CassieFox23

CassieFox23 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: At 96685a1, the 8 test files I ran pass on Node 22, 24 and 26 (92 tests each). The decimal fix survived your merge of main (21feb95). A socket URL with no port is refused. A scratch probe shows two different socket ids stay two sockets. But no test in the PR checks that. Still not run: a real Chrome, and a merge with the current main.

Edit (8 Nov): I ran the new head, 69f6099, in a VM, and the results are here.

Results

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
The 8 test files (92 tests) 92 passed 92 passed 92 passed
--discovery-timeout-ms 0x10 not run refused, exit 1 not run
--discovery-timeout-ms 1e2 not run refused, exit 1 not run
--discovery-timeout-ms 16 not run accepted, then failed at the connection, exit 1 not run
20 endpoint spellings through browserObservationEndpointSchema not run see below not run
Two socket ids on the real provider, fake browsers not run 2 sockets, see below not run

Seven files are the PR's changed tests. The eighth is main's cliDecimalArguments test. My earlier run had 80 tests because it did not include browserObservation.test.ts (11 tests), and this head adds one provider test.

Only Greptile Review and Validate author declaration ran on this head. No test workflow ran, so these runs are the test results for it.

What I checked since my review above

  • Reuse-key spelling. WS://[0:0:0:0:0:0:0:1]:09222/devtools/browser/x becomes ws://[::1]:9222/devtools/browser/x, and WS://127.0.0.1:0080/... becomes ws://127.0.0.1:80/.... 127.0.0.1 and [::1] stay apart. The ids X and x stay apart. The new provider test (line 1173 of cdpBrowserProvider.browserSocket.test.ts) passes on all three Nodes.
  • Port-less socket URLs. ws://127.0.0.1/devtools/browser/x and ws://[::1]/devtools/browser/x are refused. The :80 in browserObservation.test.ts is a port written out as :0080, so no default port is guessed.
  • Two different ids. The docs say distinct /devtools/browser/<id> paths stay separate sockets. The new schema test only compares url strings. The provider test uses one path, because the fake browser in tests/fixtures/fakeCdpBrowser.ts accepts only /devtools/browser/fake. My scratch probe wrapped CdpConnection.connect to send .../idA and .../idB to two fake browsers, as the PR's IPv6 test does. I made four list calls: idA, idB, idA, then idB with a leading-zero port. That gave 2 connects, and 1 opened connection on each fake browser. So the claim holds, but a test for it is not in the PR.
  • Decimal fix. Line 34 of cliObservationOptions.ts still wraps the field in cliDecimalField. 0x10 and 1e2 are refused. 16 got past argument parsing and failed at the connection, since nothing listens on port 9.
  • Earlier points. The 21 tests in cdpBrowserProvider.browserSocket.test.ts all pass, including the abort and cold-start ones from my review above. They use a fake browser, not a real Chrome.
  • Merge with main. GitHub reports the PR as mergeable with main (b81da90). I ran no tests on a merge.

Still not run

  • A real Chrome 136+ and its consent prompt. The VM has no Chrome.
  • Tests on a merge with the current main (b81da90).
  • Any test beyond the 8 named files, and any CI workflow. None ran on this head.
Test setup
  • Box: Fedora 44 VM, Linux 7.2.11, on my Nobara 44 PC
  • CPU: 4 vCPUs
  • RAM: 8 GB
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 96685a1 / 015a02d (merge base with main)
  • Other: VM reverted to clean-6.8.0 before the run. The probes are scratch scripts, not PR code. Main was b81da90 when I checked.
Commands
Command Node Exit Wall
npm ci --offline 24.22.1 0 about 20 s (estimate)
npm run prepare and npm run test:prepare 24.22.1 0, 0 14 s together
xvfb-run -a npm run test:focused -- <the 8 test files> 24.22.1 0 29 s
same command 22.23.4 0 28 s
same command 26.12.1 0 24 s
scratch tsx probe: 20 endpoint spellings through browserObservationEndpointSchema 24.22.1 0 about 1 s
scratch tsx probe: provider with two fake browsers, ids idA and idB 24.22.1 0 about 1 s
node scripts/rea.mjs list-browser-targets http://127.0.0.1:9 --discovery-timeout-ms 0x10 --format json 24.22.1 1 5 s for all three runs
same with 1e2 24.22.1 1 in the 5 s
same with 16 24.22.1 1 in the 5 s

The eight files: src/domain/browserObservation.test.ts, src/domain/webDeadlineControls.test.ts, tests/boundary/browser/cdpBrowserProvider.browserSocket.test.ts, tests/boundary/browser/cdpTargetDeadlines.test.ts, tests/boundary/browser/cdpTargetSessionOwner.test.ts, tests/boundary/browser/webDeadlineBehavior.test.ts, tests/boundary/mcp/browserMcp.test.ts, tests/boundary/cli/cliDecimalArguments.test.ts. None of them calls doctor.

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I ran head 69f6099 in a VM, and the PR's 7 changed test files pass on Node 22, 24 and 26. A new test covers the gap from my review above: two different socket ids now stay two sockets.

The new test is keeps distinct /devtools/browser/<id> paths on separate browser sockets while reusing each normalized path.

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
PR's 7 changed test files pass, 92 of 92 tests pass, 92 of 92 tests pass, 92 of 92 tests

The file tests/boundary/browser/cdpBrowserProvider.browserSocket.test.ts now has 22 tests, up from 21 at 96685a1. My review above ran 8 files, and this run is the PR's 7 only. Those 7 files had 91 tests before and have 92 now.

CI on 69f6099: CI, CodeQL production and PR title wait for a maintainer to approve them (action_required). PR readiness, Greptile Review and Validate author declaration passed. The head is 5 commits behind main b81da90, and GitHub says it is mergeable.

Not run

  • A real Chrome.
  • A merge with current main, b81da90.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 69f6099 / 015a02d (merge base with main)
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1, exit 0
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- src/domain/browserObservation.test.ts src/domain/webDeadlineControls.test.ts tests/boundary/browser/cdpBrowserProvider.browserSocket.test.ts tests/boundary/browser/cdpTargetDeadlines.test.ts tests/boundary/browser/cdpTargetSessionOwner.test.ts tests/boundary/browser/webDeadlineBehavior.test.ts tests/boundary/mcp/browserMcp.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@morluto
morluto enabled auto-merge (squash) November 8, 2026 19:07
@morluto
morluto merged commit 9d0e87f into morluto:main Nov 8, 2026
46 of 47 checks passed
@morluto morluto added area: mcp MCP server, transport, and tool registration enhancement New feature or request labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: mcp MCP server, transport, and tool registration enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants