Skip to content

fix(browser): finalize stderr before reporting attach diagnostics - #138399

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

steipete merged 1 commit into
mainfrom
codex/fix-chrome-mcp-stderr-finalization

Conversation

@steipete

@steipete steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Chrome MCP attach failures could lose their startup diagnostic even though stderr was drained from the start: the failure handler read the tail before the independently delivered stderr stream had finished. This resolves the missing-warning race without delaying the original attach error or its cleanup.

The stderr collector now publishes one final bounded tail on end/close/error. Failed startup registers a warning continuation; successful startup remains silent. The existing 8 KiB UTF-8 bound, secret and local-path redaction, and backpressure handling remain unchanged. Production grows by seven lines to replace a synchronous getter with its missing asynchronous completion boundary; no new timeout, close wrapper, configuration, or transport is added.

The real subprocess fixture now covers a diagnostic emitted only after stdin EOF. That case still fails against the original collector and passes with this repair. The test observes the asynchronous warning separately from child exit, preserving the exact count and complete payload checks.

Validation: the same complete six-case file ran before/after (only the new case fails before; all six pass after); the full Chrome MCP and bounded-tail sibling files pass 110 cases; all 25 normal changed-check stages pass; final managed Codex P0–P2 review has no actionable findings. The earlier review caught the test observation race, which was corrected and revalidated. This is functional real-child/SDK proof, not a performance claim or a live Chrome GUI session.

Follow-up retained: SDK initialization auto-close clears transport.pid before its original close finishes, so a subsequent cleanup call does not necessarily join that operation. These tests independently wait for eventual child exit; this diagnostic repair does not establish stronger close completion, descendant cleanup, replacement exclusion, or lease fencing. That lifecycle issue needs a separate owner-level repair and deterministic held-child proof.

@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 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

Please complete the review for the current head; the initial review has no completed public result.

@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:

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. 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, 1:39 PM ET / 17:39 UTC.

ClawSweeper review

What this changes

The PR changes Chrome MCP attach diagnostics so stderr is finalized after subprocess shutdown before a failed attach warning is logged.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open for protected maintainer handling. The focused repair moves stderr finalization to the collector owner and adds a real-child shutdown case; no actionable patch defect was found, but this review could not inspect the pinned MCP SDK source to independently confirm its stderr terminal-event contract.

Priority: P2
Reviewed head: 32a2b0dd62232969251fb2af4f1c0e75ab784c5e
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with targeted real-child regression coverage; the sole material review gap is independent confirmation of the pinned SDK stream lifecycle.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal diagnostic repair is exempt from the external-contributor proof gate. Its source adds a real child-process and MCP transport scenario, but this read-only review did not execute it and the PR-body validation claim was not treated as independent runtime proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal diagnostic repair is exempt from the external-contributor proof gate. Its source adds a real child-process and MCP transport scenario, but this read-only review did not execute it and the PR-body validation claim was not treated as independent runtime proof.
Evidence reviewed 6 items Current main retains the synchronous snapshot: Current main still has the collector return a synchronous getter, so an initialization failure can read the tail before shutdown-only stderr is delivered.
Repair is at the diagnostic owner: The introduced collector retains its bounded tail until end, close, or error, while the attach path reports it asynchronously without replacing the original attach error.
Regression fixture covers delayed stderr: The new real Node child writes its diagnostic only after stdin closes; the assertion waits for subprocess exit and then verifies one bounded, redacted warning.
Findings None None.
Security None None.

How this fits together

Chrome MCP is the browser plugin’s subprocess bridge to Chrome. Its attach path starts the bridge, initializes the MCP client, and emits sanitized diagnostics when initialization fails.

flowchart LR
  A[Browser attach request] --> B[Chrome MCP subprocess]
  B --> C[Stderr tail collector]
  B --> D[MCP client initialization]
  D --> E{Attach succeeds?}
  E -->|No| F[Sanitized failure diagnostic]
  E -->|Yes| G[Browser session]
  C --> F
Loading

Decision needed

Question Recommendation
Does a browser/MCP owner confirm that @modelcontextprotocol/sdk 1.30.0 preserves the piped stderr stream through the terminal event used by this collector? Confirm and merge: Confirm the pinned SDK’s stderr lifecycle matches the collector’s end/close/error boundary, then merge the focused repair.

Why: The patch is focused and source-supported, but direct inspection of the dependency contract was unavailable and this protected maintainer PR requires explicit human handling.

Before merge

  • Resolve merge risk (P2) - The repair relies on the pinned MCP SDK’s piped stderr stream reaching end, close, or error after client cleanup; direct SDK source was unavailable in this read-only environment. Production grows by seven lines, but the explicit completion boundary and nonblocking reporter are the apparent irreducible owner-level change.
  • Complete next step (P2) - A browser/MCP owner must confirm the pinned SDK stderr lifecycle contract before merge.
  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +7, Tests +7. Total +14 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 20 13 +7
Tests 1 14 7 +7
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 34 20 +14

Review metrics

Metric Value Why it matters
Owner-boundary LOC production +7, tests +7 Production growth establishes the final stream-completion boundary and nonblocking report; the added case targets that same shutdown path.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one bounded stderr collector and publish its sanitized tail only after its terminal stream event; confirm the pinned SDK lifecycle contract before merging.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one bounded stderr collector and publish its sanitized tail only after its terminal stream event; confirm the pinned SDK lifecycle contract before merging.

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

Yes, source-reproducible: the real-child fixture emits stderr only after stdin EOF, while current main reads the tail synchronously before cleanup. The read-only review did not execute the test.

Is this the best way to solve the issue?

Yes, with a remaining SDK-contract check: finalizing at the bounded collector owner removes the race without delaying the original attach failure; taking another immediate snapshot or awaiting in the attach path would not preserve those properties.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9f1c8a1c58bd.

Labels

Label changes:

  • add P2: This fixes missing diagnostics during a bounded browser attach failure without evidence of data loss, security impact, or core unavailability.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal diagnostic repair is exempt from the external-contributor proof gate. Its source adds a real child-process and MCP transport scenario, but this read-only review did not execute it and the PR-body validation claim was not treated as independent runtime proof.

Label justifications:

  • P2: This fixes missing diagnostics during a bounded browser attach failure without evidence of data loss, security impact, or core unavailability.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal diagnostic repair is exempt from the external-contributor proof gate. Its source adds a real child-process and MCP transport scenario, but this read-only review did not execute it and the PR-body validation claim was not treated as independent runtime proof.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 1f051da adds extensions/browser/src/browser/chrome-mcp-diagnostics.ts:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1f051da39d05; files: extensions/browser/src/browser/chrome-mcp-diagnostics.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm the @modelcontextprotocol/sdk 1.30.0 stderr terminal-event contract before merge.

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.

@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Resolved the SDK-contract question and Rank-up move from the completed review. I directly inspected the installed, pinned @modelcontextprotocol/sdk 1.30.0 ESM implementation and declarations, rather than inferring this from OpenClaw wrappers.

In dist/esm/client/stdio.js, the transport creates its PassThrough during construction when stderr is piped, returns that same stream before start, and pipes the child stderr into it without disabling the normal end behavior. close() ends child stdin and does not destroy or replace the stderr PassThrough. Thus the collector can attach before connect and observe the final tail through its end/close/error boundary. The installed stdio.js SHA-256 is 298514feae7875117a119a2598b40f2346ef07c30152fa7ad2ffb6cfb51782bc.

The existing paired real-child proof exercises this exact contract: the child emits its diagnostic only after stdin EOF. The original collector fails that new case; the candidate passes all six complete connect cases, plus 110 sibling cases and the 25-stage changed gate. The test independently waits for child exit and the single redacted, bounded warning. This is real SDK/subprocess proof, not a live Chrome GUI claim.

The separate SDK close-joining limitation remains explicitly in the PR body: the SDK can clear its PID before the original close finishes, and a second close does not prove that the first operation joined. This diagnostic fix does not claim descendant cleanup or lease fencing. Production +7 establishes the missing asynchronous completion boundary while reusing the existing bounded collector; no polling, timer, or replacement cleanup path is added. The dependency evidence gap is resolved for this focused repair, with no source or threshold changes.

@steipete
steipete merged commit 449703a into main Sep 4, 2026
98 checks passed
@steipete
steipete deleted the codex/fix-chrome-mcp-stderr-finalization branch September 4, 2026 18:15
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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