Repository navigation
Release a request that around_request stops before its handler - #720
Merged
koic merged 1 commit intoNov 27, 2026
Conversation
## Motivation and Context A request is registered as in flight before it is dispatched, and the registration was released in an `ensure` inside the block that `configuration.around_request` wraps. A hook that raises before calling the request handler, or that returns without calling it, never ran that block, so the request stayed in flight after it had been answered. This kept the request id from being used again on that session. Since a session with a request in flight is kept from idle expiry, it also kept the session from ever expiring, and with `max_sessions:` its slot from being given to another client. The registration is now released around the instrumentation, whatever the hook does. ## How Has This Been Tested? `test/mcp/server_cancellation_test.rb` and `test/mcp/server/transports/streamable_http_transport_test.rb`. Against the previous library the request is still in flight after the hook refused it. ## Breaking Changes None.
koic
deleted the
release_a_request_that_around_request_stops_before_its_handler
branch
November 27, 2026 06:04
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
A request is registered as in flight before it is dispatched, and the registration was released in an
ensureinside the block thatconfiguration.around_requestwraps. A hook that raises before calling the request handler, or that returns without calling it, never ran that block, so the request stayed in flight after it had been answered.This kept the request id from being used again on that session. Since a session with a request in flight is kept from idle expiry, it also kept the session from ever expiring, and with
max_sessions:its slot from being given to another client.The registration is now released around the instrumentation, whatever the hook does.
How Has This Been Tested?
test/mcp/server_cancellation_test.rbandtest/mcp/server/transports/streamable_http_transport_test.rb. Against the previous library the request is still in flight after the hook refused it.Breaking Changes
None.
Types of changes