Repository navigation
Conversation
A modern Streamable HTTP request could wait until its read timeout after the server closed the response stream without replying. Reject with ConnectionClosed when the stream ends, including when a request resumed with a saved token gets HTTP 405. Validation: all 126 tests in the transport and protocol test files passed. Lint and type checks passed for client and core-internal.
🦋 Changeset detectedLatest commit: 3e50bd0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
|
Great fix, @anupamgit — handling premature stream termination and forwarding Two production observations from our test harness that might be helpful for this path: 1. Terminal vs Transient Resumption StatusesClassifying HTTP 405 Method Not Allowed as a terminal, non-resumable status is spot on. For production resilience, it's worth ensuring HTTP 404 (session expired/evicted) and HTTP 410 (Gone) are treated as terminal as well, so the client doesn't enter futile retry loops:
2. Timers & Listener Cleanup on Stream EndWhen On the server side, pairing this with guaranteed terminal JSON-RPC error frames ( (Disclosure: I maintain A7mdMe/mcp-production-kit, where we test and harden production MCP client/server boundary defenses). |
A modern Streamable HTTP request could wait until its read timeout after the server closed the response stream without replying. Reject with ConnectionClosed when the stream ends, including when a request resumed with a saved token gets HTTP 405.
Validation: all 126 tests in the transport and protocol test files passed. Lint and type checks passed for client and core-internal.
Motivation and Context
On modern Streamable HTTP, an in-flight client request could stay pending until read timeout when the per-request SSE stream ended without a JSON-RPC result. The same hang could occur when resuming with a saved
resumptionTokenand the GET resume ended terminally (e.g. HTTP 405), becauseonRequestStreamEndwas not wired throughProtocoland was not forwarded on the explicit resumption GET path inStreamableHTTPClientTransport.How Has This Been Tested?
pnpm --filter @modelcontextprotocol/client exec vitest run test/client/streamableHttp.test.ts— 76 passed (including new explicitresumptionToken+ 405 case)pnpm --filter @modelcontextprotocol/core-internal exec vitest run test/shared/protocol.test.ts— 50 passed (including remote stream end →ConnectionClosed)pnpm --filter @modelcontextprotocol/clientandpnpm --filter @modelcontextprotocol/core-internal— lint and typecheck passedpnpm lint:allwas not run to completion here (pre-push hook fails on unrelatedtest/helpersESLint)Breaking Changes
None. Callers see faster
ConnectionClosedrejection instead of waiting for read timeout when the stream ends without a response on the paths above.Types of changes
Checklist
ConnectionClosedvia existingcancel()path)Additional context
.changeset/reject-when-per-request-stream-ends.md(patch).