Repository navigation
fix(mcp): keep shared optional providers open across discarded probes - #2205
Merged
Merged
Conversation
startMcpTransport loads optional observation providers once per process and passes them to every server instance the SDK constructs. Each instance's closeProviders also closed the shared browser scenario provider, so when the SDK discarded a server/discover probe instance for a legacy initialize, every later capture_browser_scenario call failed with "Browser scenario provider is closing." Server instances no longer close the caller-supplied provider; the transport returns closeOptionalProviders and process shutdown closes it once. Fixes #2195 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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. |
3 tasks done
3 of 22 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
startMcpTransportloads the optional observation providers once per process and spreads them into every server instance the SDK constructs.createServer'scloseProvidersalso closedoptions.browserScenarioCapture, a provider the instance did not create. A client can open withserver/discoverand then fall back to a legacyinitialize. The SDK then discards the probe instance, and closing it closed the process-wide browser scenario provider. Every latercapture_browser_scenariocall on that server process failed within milliseconds withcleanup_incomplete/ "Browser scenario provider is closing."Ownership now follows creation:
createServerno longer closes the caller-supplied browser scenario provider. The per-instance services it creates itself are still closed as before.startMcpTransportreturnscloseOptionalProviders, andcreateShutdownregisters it next tocloseAndroid, so the shared provider is closed once at process shutdown.Fixes #2195
Reproduction (raw JSON-RPC over
rea mcpstdio, scenario with a nonexistentexecutable_pathso no browser is needed)Validation
tests/boundary/process/browserScenarioProbeLifecycle.test.tsmirrors the existing Android discovery-probe test. It constructs a probe server, closes it, constructs the replacement, and asserts that the shared provider'scloseis not called;transport.closeOptionalProviders()then closes it once. It fails on main (close called twice) and passes with this change.shutdown,androidAnalysisMcp,browserScenarioMcp,browserScenarioCleanupandoptionalProviderIsolationtests pass.npm run lintpasses.npm test: 9184 passed, 14 failed in 7 files. These are the same environmental files that fail on cleanorigin/mainon this host: Hopper not installed, Command Line Tools only (ibtool),hdiutil, and inspector target-location cases.🤖 Generated with Claude Code