Skip to content

fix(server): replay request SSE responses after closeSSEStream#2152

Open
fallintoplace wants to merge 2 commits into
modelcontextprotocol:mainfrom
fallintoplace:fix-close-sse-request-replay
Open

fix(server): replay request SSE responses after closeSSEStream#2152
fallintoplace wants to merge 2 commits into
modelcontextprotocol:mainfrom
fallintoplace:fix-close-sse-request-replay

Conversation

@fallintoplace
Copy link
Copy Markdown

Summary

  • persist request-scoped SSE replay events even after closeSSEStream() detaches the live controller
  • avoid throwing when a terminal SSE response arrives during the reconnect window and replay is still possible
  • add regression coverage in the shared server transport tests and the Node Streamable HTTP wrapper tests

Root cause

closeSSEStream() intentionally removes the active response stream so a long-running request can continue while the client reconnects. The request-scoped send() path still treated the live controller as a prerequisite for storing replay events, so a terminal response produced during that reconnect window could not be replayed and instead failed with No connection established for request ID.

Validation

  • npx -y pnpm@10.26.1 --filter @modelcontextprotocol/server test -- test/server/streamableHttp.test.ts
  • npx -y pnpm@10.26.1 --filter @modelcontextprotocol/node test -- test/streamableHttp.test.ts
  • npx -y pnpm@10.26.1 --filter @modelcontextprotocol/server typecheck
  • npx -y pnpm@10.26.1 --filter @modelcontextprotocol/node typecheck
  • npx -y pnpm@10.26.1 --filter @modelcontextprotocol/server lint
  • npx -y pnpm@10.26.1 --filter @modelcontextprotocol/node lint
  • ASDF_NODEJS_VERSION=24.15.0 git push -u origin fix-close-sse-request-replay (repo pre-push hook: build, typecheck, lint)

Fixes #2151

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 24, 2026

⚠️ No Changeset found

Latest commit: 7fb7156

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 24, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@2152

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/codemod@2152

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@2152

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@2152

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/fastify@2152

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@2152

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@2152

commit: 7fb7156

@fallintoplace fallintoplace marked this pull request as ready for review May 24, 2026 10:59
@fallintoplace fallintoplace requested a review from a team as a code owner May 24, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

closeSSEStream() breaks request-scoped SSE resumability for terminal responses

1 participant