Repository navigation
fix(mcp): clean up retired stdio runtimes after calls finish - #992
Conversation
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. |
There was a problem hiding this comment.
Code Review
This pull request implements a synchronized shutdown and retirement mechanism for the MCP runtime, ensuring that active bindings finish processing before connections are closed. It introduces an RwLock for connection access, a retired flag, and waits for the strong count of connections to drop to 1 during shutdown. The test suite is also updated with robust file-based synchronization and Linux-specific pipe descriptor checks. Feedback on these changes recommends adding a timeout or retry limit when waiting for the Arc::strong_count to drop to 1 during shutdown to prevent potential infinite hangs if a binding is leaked.
Summary
Retiring an MCP snapshot preserves connections held by active bindings. Superseded clients shut down asynchronously after their last owner drops. Ending the runtime prevents new snapshot acquisition or publication and shuts down an idle set immediately; sets retained by in-flight bindings are cleaned up by their last owner.
The cleanup integration test verifies successful in-flight calls across refresh and shutdown, followed by child-process exit and Linux stdio pipe release.
Validation
The exact-head GitHub-hosted validation-lab run 40121187168 passed on code commit
007d199d7543eaa333d622eb07c608fa28f019ba. Thecodex.mcp-tool-exposure-targetedlane passed the lifecycle regression (1 passed, 1 slow, 1036 skipped). The later successorb3f34751152e7c96183a356875602d6ab8f0cdeaadds only the required carry documentation; all current-head PR checks are terminal with 81 successes, 0 failures, and 0 pending (19 skipped, 1 neutral).