Repository navigation
Conversation
…dently A slow request-scoped request must not hold up the next one, and notifications/cancelled must reach it while it runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tart The serial phase holds inbound requests inline until the handshake completes. A 2026-07-28 client never sends notifications/initialized, so on a persistent connection every request-scoped request waited behind the previous one and notifications/cancelled could not reach a running handler. Only handshake-lifecycle requests are held to that order now. The request-scoped HTTP exchange relied on delivery returning only once the handler answered; it now waits for the answer itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…atch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
Follow-up to #985. That review asked for each confirmed finding to become its own fix PR with green CI. This one is the HIGH finding. On a persistent connection (stdio, WebSocket, an in-memory pair), a 2026-07-28 client's requests were served one at a time, and
notifications/cancelledwas ignored. The serial dispatch phase only ends onnotifications/initialized, and a request-scoped client never sends that. So a slowtools/callblocked every later request until it finished, and nothing could cancel it. The spec lets clients interleave unrelated requests freely (basic/index, Statelessness) and cancel in-flight ones.What changed
Protocol.dispatchRequestholds only handshake-lifecycle requests to the serial phase. A request that carries the protocol-version envelope has no initialization phase, so it goes through concurrent dispatch with in-flight tracking from the first message.SingleExchangeTransport.deliver(request-scoped HTTP) now waits for the exchange's answer. It used to rely on inline dispatch returning only after the handler answered. Without this change, every handler that suspends was reported as "returned without producing a response".Scope
Legacy pre-initialize ordering is unchanged.
initializeand anything sent beforenotifications/initializedwithout an envelope still run inline in arrival order. Notifications still run inline until the handshake completes, sonotifications/cancelledis handled on the delivery loop.Tradeoffs
On request-scoped HTTP, the handler now runs on the session's handler scope rather than on the call's coroutine. A client disconnect still cancels it, through
session.close()in the exchange'sfinally, as the disconnect test shows.Blast Radius
Server and client
Protocoldispatch for enveloped requests. Request-scoped requests are now subject tomaxConcurrentHandlersandmaxInFlightHandlers, like post-handshake legacy requests.Verification
EraInterleavingTest:a request-scoped request is answered while an earlier one is still runninganda running request-scoped request is cancelled by notifications cancelledboth failed withTimeoutCancellationException: Timed out waiting for 5000 ms. They pass after the fix.Protocolchange failedModernStreamableHttpStreamTestandModernStreamableHttpDisconnectTestwith "The request handler returned without producing a response". Thedeliverchange fixes both.:kotlin-sdk-core,:kotlin-sdk-server,:kotlin-sdk-clientand:integration-testjvmTest, plusktlintCheck detekt checkKotlinAbi, all pass.🤖 Generated with Claude Code