Repository navigation
fix(browser): finalize stderr before reporting attach diagnostics - #138399
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper review Please complete the review for the current head; the initial review has no completed public result. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: blocked before merge. Reviewed September 4, 2026, 1:39 PM ET / 17:39 UTC. ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherChrome 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
Decision needed
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
Agent review detailsSecurityNone. PR surfaceSource +7, Tests +7. Total +14 across 3 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
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. |
|
Merged via squash.
|
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.