Repository navigation
Conversation
## Motivation and Context `StreamableHTTPTransport#close` joins the session reaper and kills it if it is still alive after the wait. When `close` itself runs on the reaper thread, reached from a stream's `close` or from the exception reporter while a reap is in progress, that join raises `ThreadError`, the rescue around it treats the reaper as gone, and the kill that follows ends the reaper, which is the thread running `close`: the listen streams are never torn down and the sessions never cleaned up, with nothing reporting it. `close` now joins and kills the reaper only when running on another thread. On the reaper itself it goes straight to the teardown, and the reaper leaves its loop on `@closing` once the reap that called `close` returns. ## How Has This Been Tested? A new test in `test/mcp/server/transports/streamable_http_transport_test.rb` reaps a session whose stream's `close` calls `transport.close`, and checks that the listen stream is torn down, the sessions are gone, and the reaper ends without an exception. Against the previous library it fails: the listen registry still holds its entry. ## Breaking Changes None.
This branch has not been deployed
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.
Motivation and Context
StreamableHTTPTransport#closejoins the session reaper and kills it if it is still alive after the wait. Whencloseitself runs on the reaper thread, reached from a stream'scloseor from the exception reporter while a reap is in progress, that join raisesThreadError, the rescue around it treats the reaper as gone, and the kill that follows ends the reaper, which is the thread runningclose: the listen streams are never torn down and the sessions never cleaned up, with nothing reporting it.closenow joins and kills the reaper only when running on another thread. On the reaper itself it goes straight to the teardown, and the reaper leaves its loop on@closingonce the reap that calledclosereturns.How Has This Been Tested?
A new test in
test/mcp/server/transports/streamable_http_transport_test.rbreaps a session whose stream'sclosecallstransport.close, and checks that the listen stream is torn down, the sessions are gone, and the reaper ends without an exception. Against the previous library it fails: the listen registry still holds its entry.Breaking Changes
None.
Types of changes
Checklist