Repository navigation
fix: cancel native MCP captures when stdio reaches EOF - #52
Merged
Merged
Conversation
fcostaoliveira
marked this pull request as ready for review
October 23, 2026 20:54
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.
Closing an MCP client's stdin during capture leaves the server waiting for the active handler on the supported MCP 1.24 floor. The capture can continue until its deadline because that SDK version does not cancel handlers when the transport ends.
The POSIX stdio boundary now cancels its request scope at EOF and waits for the existing shielded native cleanup. The same reproduced Stax control changed from still running three seconds after EOF to a clean exit in about 86 ms. Partial artifacts remain available and attached targets are not signaled. HTTP retains its existing server handling.
Tests cover active native cleanup on EOF and SIGTERM, a child ignoring SIGTERM, descriptor restoration, and a simulated older SDK that waits indefinitely after input closes. Validation: focused lifecycle/protocol suite 26 passed; full macOS suite 2,120 passed / 109 skipped; full Linux aarch64 suite with real PostgreSQL 16.15 2,186 passed / 43 skipped; Ruff and all six CI checks passed.
An installed-wheel control with real Linux Stax binaries and MCP 1.24.0 exited cleanly about 170 ms after EOF, retained a valid partial archive, reaped native children, left the attached target alive and created no automatic database. Explicitly importing the partial archive recovered 13 CPU samples from its actual 1.07-second window.