Skip to content

fix(mcp): clean up retired stdio runtimes after calls finish - #992

Merged
GraciousGazelles merged 11 commits into
mainfrom
fix/mcp-retired-connection-shutdown-20261025
Oct 24, 2026
Merged

GraciousGazelles merged 11 commits into
mainfrom
fix/mcp-retired-connection-shutdown-20261025

Conversation

@GraciousGazelles

@GraciousGazelles GraciousGazelles commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

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. The codex.mcp-tool-exposure-targeted lane passed the lifecycle regression (1 passed, 1 slow, 1036 skipped). The later successor b3f34751152e7c96183a356875602d6ab8f0cdea adds only the required carry documentation; all current-head PR checks are terminal with 81 successes, 0 failures, and 0 pending (19 skipped, 1 neutral).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-10-24T16:41:37.525546Z d5b98e3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread codex-rs/codex-mcp/src/runtime.rs Resolved
@GraciousGazelles
GraciousGazelles added this pull request to the merge queue Oct 24, 2026
Merged via the queue into main with commit 493bfd4 Oct 24, 2026
101 checks passed
@GraciousGazelles
GraciousGazelles deleted the fix/mcp-retired-connection-shutdown-20261025 branch October 24, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants