Skip to content

test(browser): cover stderr backpressure during MCP startup - #138022

Merged
steipete merged 1 commit into
mainfrom
fix/chrome-mcp-stderr-before-handshake
Sep 4, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/chrome-mcp-stderr-before-handshake

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Canonical runtime fix: #137993
Related broader recovery work: #135868

What Problem This Solves

Adds a regression for a real MCP child whose initialize reply waits for a large stderr write to finish. #137993 already landed the early stderr drain and startup diagnostics; this PR now contains only complementary test coverage, with no production changes.

Why This Change Was Made

A small diagnostic write does not prove pipe-backpressure liveness. Extend #137993's existing real-child fixture instead of retaining this PR's separate subprocess fixture: the successful-startup case now covers zero and 2 MiB of stderr, with the initialize response gated by the actual write callback. Input handling stays active throughout so shutdown can still consume EOF. Existing 9 KB failure/redaction cases, real tool-call assertions, bounded diagnostic checks and exact-child cleanup checks remain in place. Net change: eight test lines; zero production lines.

User Impact

No new behavior, configuration, dependency, retry or timeout. The test protects the initialization fix already owned by #137993 against a future move back to post-handshake stderr draining.

Evidence

On the pinned main composition, temporarily substituting the exact pre-drain connection owner from the parent of #137993 produced the intended RED: quiet passed; the 2 MiB case failed with the unchanged production 30-second handshake timeout. Cleanup assertions passed. Restoring the exact current-main owner made the identical two cases GREEN. The existing 40-second regression case bound was retained; no timeout was increased.

All five relevant owner/sibling suites passed: 140 tests, zero failures/skips, including all three existing startup diagnostic failure cases, both startup/tool-call controls, session ownership, snapshot behavior and bounded UTF-8 diagnostics.

node scripts/run-vitest.mjs extensions/browser/src/browser/chrome-mcp-connect.test.ts extensions/browser/src/browser/chrome-mcp.test.ts extensions/browser/src/browser/chrome-mcp.ownership.test.ts extensions/browser/src/browser/chrome-mcp.snapshot.test.ts extensions/browser/src/browser/bounded-utf8-tail.test.ts
node scripts/check-changed.mjs -- extensions/browser/src/browser/chrome-mcp-connect.test.ts

Fresh independent Codex review through P3 found no actionable findings. The full canonical changed-file gate passed all 19 selected stages, including extension-test typechecking, formatting, all three Knip scans, dependency/plugin guards and scoped lint (595.181 seconds). Exact-head CI run 33853333970 attempt 2 is green; only the incomplete advisory audit and its dependent gate were rerun on the unchanged head. Earlier-head CI is not reused. This is real local subprocess/stdio proof, not a physical Chrome UI session. The cause of the original Watch CI timeout remains unproven. The broader #135868 work remains untouched.

Two local setup failures were preserved: an inherited CI setting selected unavailable Corepack, and the initial review PATH omitted the installed Codex CLI. The normal local package-manager environment and explicit installed CLI resolved those setup issues without product, assertion, or timeout changes.

Final SDK and CI verification

Direct SDK inspection closes the remaining reviewer limitation: the installed @modelcontextprotocol/sdk 1.30.0 creates and exposes its stderr PassThrough in the constructor, pipes the child into it during start(), and closes via stdin EOF followed by bounded TERM/KILL escalation. This confirms the pre-connect drain contract already implemented by #137993; no SDK or production code changes are needed here.

For exact head a5d40b84d7625d6e9e0154c537c5d4362120535f, the identical real-child RED/GREEN, all 140 owner/sibling tests, all 19 changed-file stages, and fresh independent Codex review through P3 are complete. CI attempt 2 is green after an unchanged-head rerun of the incomplete advisory audit and its dependent gate. The latest Claw review found no introduced correctness defects. This is real local subprocess/stdio evidence, not a physical Chrome UI session or proof of the original Watch CI timeout's cause.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review September 4, 2026 07:19
@steipete steipete self-assigned this Sep 4, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 4:54 AM ET / 08:54 UTC.

ClawSweeper review

What this changes

Extends the browser plugin’s existing subprocess test with quiet and 2 MiB stderr cases whose initialization replies wait for the write to complete.

Merge readiness

⛔ Blocked before merge - 1 item remains

The rewritten PR retains useful backpressure coverage absent from current main. The prior composition concern is resolved, and no introduced correctness defect was found.

Priority: P2
Reviewed head: a5d40b84d7625d6e9e0154c537c5d4362120535f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused, useful regression coverage with supplied real-subprocess before/after evidence and no actionable patch findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The supplied before/after report exercises the production session lease and real MCP stdio client against a local Node subprocess: callback-gated 2 MiB startup times out with the pre-drain owner, then completes initialization, tool calls, and child cleanup with the current owner. This proves the targeted transport behavior; it does not diagnose the separate Chrome UI timeout.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The supplied before/after report exercises the production session lease and real MCP stdio client against a local Node subprocess: callback-gated 2 MiB startup times out with the pre-drain owner, then completes initialization, tool calls, and child cleanup with the current owner. This proves the targeted transport behavior; it does not diagnose the separate Chrome UI timeout.
Evidence reviewed 9 items Verified introduction and merge composition: The pinned merge-base-to-head delta changes only the subprocess test. The test merge has the recorded base and exact PR head as its parents; comparison against that base also changes only this test.
Meaningful regression boundary: Initialization replies are gated by the stderr write callback. The table covers zero and 2 MiB, checks an actual tool result and absence of warnings, and retains stdin EOF, exact-child disappearance, and cached-PID cleanup assertions. Each case receives fresh options and state.
Current-main owner and missing coverage: Current main already attaches the stderr collector before client.connect, but its existing success test neither writes 2 MiB nor gates initialization on write completion. The PR therefore adds distinct coverage without duplicating the runtime repair.
Findings None None.
Security None None.

How this fits together

The browser plugin uses an MCP subprocess to control an existing Chrome session. Its connection owner drains subprocess diagnostics while initialization completes, then admits browser tool calls.

flowchart LR
  A[Browser operation] --> B[Session lease]
  B --> C[MCP connection owner]
  C --> D[Browser control subprocess]
  D --> E[Bounded stderr collector]
  E --> F[Initialization completes]
  F --> G[Tool result and cleanup]
Loading

Before merge

  • Resolve merge risk (P1) - Reviewer limitation: fresh inspection of MCP SDK 1.30.0 was unavailable; dependency behavior is supported here by the supplied merged-PR inspection record and subprocess results.
Agent review details

Security

None.

PR surface

Tests +8. Total +8 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 23 15 +8
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 23 15 +8

Review metrics

Metric Value Why it matters
Production versus test growth Production net 0; tests net +8 The added coverage reuses the existing fixture and introduces no production maintenance surface.

Root-cause cluster

Relationship: partial_overlap
Canonical: #137993
Summary: The merged PR owns the runtime repair; this PR contributes complementary backpressure coverage. The broader recovery proposal remains separate.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the single early stderr collector and protect its liveness through the existing real-subprocess fixture, without another runtime path or test-only production seam.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the single early stderr collector and protect its liveness through the existing real-subprocess fixture, without another runtime path or test-only production seam.

Do we have a high-confidence way to reproduce the issue?

Not applicable to a remaining current-main bug: the runtime repair has landed. The supplied controlled before/after run reports the intended verbose-startup failure with the old owner and success with the current owner.

Is this the best way to solve the issue?

Yes for the inspected OpenClaw boundary: extending the existing fixture adds a meaningful liveness assertion while preserving diagnostic and cleanup checks, with no parallel implementation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 216360ad87d8.

Labels

Label justifications:

  • P2: Focused regression coverage protects browser subprocess initialization from a credible backpressure stall.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The supplied before/after report exercises the production session lease and real MCP stdio client against a local Node subprocess: callback-gated 2 MiB startup times out with the pre-drain owner, then completes initialization, tool calls, and child cleanup with the current owner. This proves the targeted transport behavior; it does not diagnose the separate Chrome UI timeout.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied before/after report exercises the production session lease and real MCP stdio client against a local Node subprocess: callback-gated 2 MiB startup times out with the pre-drain owner, then completes initialization, tool calls, and child cleanup with the current owner. This proves the targeted transport behavior; it does not diagnose the separate Chrome UI timeout.

Evidence

What I checked:

  • Verified introduction and merge composition: The pinned merge-base-to-head delta changes only the subprocess test. The test merge has the recorded base and exact PR head as its parents; comparison against that base also changes only this test. (extensions/browser/src/browser/chrome-mcp-connect.test.ts:46, 0ef1a8c1bd69)
  • Meaningful regression boundary: Initialization replies are gated by the stderr write callback. The table covers zero and 2 MiB, checks an actual tool result and absence of warnings, and retains stdin EOF, exact-child disappearance, and cached-PID cleanup assertions. Each case receives fresh options and state. (extensions/browser/src/browser/chrome-mcp-connect.test.ts:57, a5d40b84d762)
  • Current-main owner and missing coverage: Current main already attaches the stderr collector before client.connect, but its existing success test neither writes 2 MiB nor gates initialization on write completion. The PR therefore adds distinct coverage without duplicating the runtime repair. (extensions/browser/src/browser/chrome-mcp-connect.ts:65, 216360ad87d8)
  • Caller, shared lifecycle, and diagnostic owner: Browser availability and tab listing enter withChromeMcpLease; persistent and ephemeral leases share createChromeMcpSession. The diagnostic callee continuously consumes stderr into a bounded UTF-8 tail. Existing failure cases still cover persistent and ephemeral initialization failures plus tool-discovery failure. (extensions/browser/src/browser/chrome-mcp-diagnostics.ts:13, a5d40b84d762)
  • Captured real-subprocess proof: The supplied PR body, captured under sourceRevision 200b85abc8534089088010f04a0c9d0b362a5f7a983006a38b0b7c0968c456cd, reports quiet PASS and 2 MiB handshake-timeout RED with the pre-drain owner, then both GREEN with the current owner and successful cleanup. It also reports 140 passing owner/sibling tests and 19 passing changed-file stages. These are supplied execution results, not reviewer-run tests. (extensions/browser/src/browser/chrome-mcp-connect.test.ts:131, a5d40b84d762)
  • Prior review disposition: The retained rank-up requested quiet/2 MiB coverage and one early collector during conflict reconciliation. Both are preserved by this rewrite. The earlier reviewed object is unavailable locally, so no unsupported line-by-line continuity claim is made. (extensions/browser/src/browser/chrome-mcp-connect.test.ts:131, a5d40b84d762)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-04T07:41:09.213Z sha bd06637 :: blocked before merge. :: none
  • reviewed 2026-09-04T07:49:04.908Z sha bd06637 :: blocked before merge. :: none

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.
@steipete
steipete force-pushed the fix/chrome-mcp-stderr-before-handshake branch from bd06637 to a5d40b8 Compare September 4, 2026 08:25
@steipete steipete changed the title fix(browser): prevent verbose MCP startup from deadlocking test(browser): cover stderr backpressure during MCP startup Sep 4, 2026
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

This PR has been rewritten as test-only coverage after #137993 landed the canonical runtime fix. It extends that existing real-child fixture with quiet/2 MiB callback-gated startup cases instead of retaining a duplicate runtime change or subprocess fixture. The identical test reproduced the pre-drain handshake timeout and passed on main; all 140 owner/sibling tests and 19 changed checks passed.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Direct SDK inspection closes the remaining reviewer limitation: the installed @modelcontextprotocol/sdk 1.30.0 creates and exposes its stderr PassThrough in the constructor, pipes the child into it during start(), and closes via stdin EOF followed by bounded TERM/KILL escalation. This confirms the pre-connect drain contract already implemented by #137993; no SDK or production code changes are needed here.

For exact head a5d40b84d7625d6e9e0154c537c5d4362120535f, the identical real-child RED/GREEN, all 140 owner/sibling tests, all 19 changed-file stages, and fresh independent Codex review through P3 are complete. CI attempt 2 is green after an unchanged-head rerun of the incomplete advisory audit and its dependent gate. The latest Claw review found no introduced correctness defects. This is real local subprocess/stdio evidence, not a physical Chrome UI session or proof of the original Watch CI timeout's cause.

@steipete
steipete merged commit 010a0ba into main Sep 4, 2026
145 of 148 checks passed
@steipete
steipete deleted the fix/chrome-mcp-stderr-before-handshake branch September 4, 2026 09:21
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: browser maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant