Repository navigation
fix(cleanup): restore shared ownership across browser, capture, and adb boundaries - #4345
SoufianoDev wants to merge 2 commits into
Conversation
…db boundaries Own shared MCP observation providers in the transport instead of closing them per server, keep step-level cancellation as the terminal scenario representation, and stop resolving unrelated cleanup on service close. Relax the adb reinstall assertion to the staged snapshot path. Verified the 7 previously failing tests plus serverLifecycle, build, typecheck, and lint locally.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[High impact] The PR appears safe to merge; the shared-provider cleanup gap is fixed. SummaryThis PR restores shared cleanup ownership and preserves step-level cancellation results.
Review used source inspection; tests were not run. Whether another PR supersedes this one could not be checked because GitHub authentication was unavailable. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
Transport["MCP transport"] --> Shared["Three shared observation providers"]
Transport --> Probe["Discovery probe server"]
Transport --> Replacement["Replacement server"]
Probe --> ProbeClose["Close server-owned resources only"]
Replacement --> ServerClose["Close server-owned resources only"]
Shutdown["Process shutdown"] --> SharedClose["Close all shared providers"]
SharedClose --> Success["Remove successful closes"]
SharedClose --> Failure["Retain failed closes for retry"]
Reviews (2) · Last reviewed commit: "fix(mcp): close all shared observation p..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a12cc09ce1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| environment: serverContext.environment, | ||
| delivery: serverContext.delivery, | ||
| ...optionalProviders, | ||
| optionalObservationProviderOwner: "caller", |
There was a problem hiding this comment.
Close every caller-owned optional provider at shutdown
In the stdio MCP path, optionalProviders can include shared browserObservation and electronObservation instances, and setting this owner makes every SDK-created server skip their close() calls, while startMcpTransport.closeOptionalProviders closes only browserScenarioCapture. After either CDP provider retains a WebSocket whose operation-level close failed, process shutdown therefore never invokes its CdpTargetSessionOwner.close(), so the transport can remain live and shutdown can report success without retrying it; include both transferred CDP providers in the caller-owned cleanup path.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
| @@ -35,8 +35,6 @@ export const finishAnalysisCommand = async < | |||
| } | |||
| try { | |||
| await service.close(); | |||
There was a problem hiding this comment.
Resolve CDP cleanup before projecting the original error
For one-shot browser, Electron, or web-runtime CLI commands, if CdpTargetSessionOwner.finish() reports a socket cleanup failure and the subsequent service.close() retry succeeds, this function now projects the original error unchanged. CdpTargetSessionOwner.#closeAll() removes the retained connection but does not resolve, or retain a link to, the returned ProviderCleanupError or wrapper, so callers still receive cleanup_incomplete and recovery instructions for an already released resource; migrate that resolution to the exact owner before removing this fallback.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
Caller-owned browserObservation and electronObservation previously received no final close once servers stopped closing them. The transport now closes all three shared providers with retry for failures, keeping successful closes settled.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 34468b12f9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if ( | ||
| options.signal?.aborted === true && | ||
| steps.every((step) => step.status === "completed") |
There was a problem hiding this comment.
Preserve cleanup-time cancellation after failed steps
When an action has already produced a failed step and the abort arrives while session.close() is pending, steps.every(...) is false, so this new guard skips the cancellation error; captureBrowserScenario's new non-completed-step fast path then returns successful Evidence. That makes final-cleanup cancellation disappear from MCP results (and emits ordinary Evidence from the CLI despite its interrupt exit code), whereas the same abort after completed steps is retained as an AnalysisCancelledError; distinguish request-cancelled steps from pre-existing failures before bypassing the late-cancellation projection.
AGENTS.md reference: AGENTS.md:L23-L23
Useful? React with 👍 / 👎.
|
Thank you for the fix! All four parts of this change have already landed on main: |
Fixes the 7 CI failures on main (run 38833320851), all regressed in the 93c620c/3b698645a batch, not in the adb hash-cleanup commits.
Observable outcome: the 7 failing tests pass locally (plus the contradicted serverLifecycle neighbor).
Approach:
Evidence (actually ran): targeted suites green (Playwright provider 20/20, capture/signal/adbCli/probeLifecycle, SIGINT+SIGTERM acceptance, serverLifecycleMcp, finishAnalysisCommand, capture service), plus build, typecheck, and lint. Full 7-shard CI not run.
Author readiness left for the human owner.