Repository navigation
Conversation
## Motivation and Context modelcontextprotocol#709 made `release_session` cancel a terminated session's requests and wake its waits before it closes the session's streams, since a close can block for up to `stream_write_timeout:` on a stalled peer. `release_sessions`, which `close` and the reaper use for sessions that end together, still released them one after the other, so each session waited for the closes of those ahead of it: its requests kept running uncancelled meanwhile, and its waits, which were woken under the lock before modelcontextprotocol#709, now waited as well. `release_sessions` now cancels the requests and wakes the waits of every session first, and closes the streams in a second pass. `release_session` does the same two steps for its one session. The second pass runs whatever the first one does, so an error while ending the requests leaves no stream open. ## How Has This Been Tested? `test/mcp/server/transports/streamable_http_transport_test.rb`; the test in which a session is cancelled while the stream of the one ahead of it is still closing times out on the previous library. ## 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
#709 made
release_sessioncancel a terminated session's requests and wake its waits before it closes the session's streams, since a close can block for up tostream_write_timeout:on a stalled peer.release_sessions, whichcloseand the reaper use for sessions that end together, still released them one after the other, so each session waited for the closes of those ahead of it: its requests kept running uncancelled meanwhile, and its waits, which were woken under the lock before #709, now waited as well.release_sessionsnow cancels the requests and wakes the waits of every session first, and closes the streams in a second pass.release_sessiondoes the same two steps for its one session. The second pass runs whatever the first one does, so an error while ending the requests leaves no stream open.How Has This Been Tested?
test/mcp/server/transports/streamable_http_transport_test.rb; the test in which a session is cancelled while the stream of the one ahead of it is still closing times out on the previous library.Breaking Changes
None.
Types of changes
Checklist