Skip to content

fix(server): keep idle GET SSE streams alive#2124

Open
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/get-sse-keepalive
Open

fix(server): keep idle GET SSE streams alive#2124
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/get-sse-keepalive

Conversation

@he-yufeng
Copy link
Copy Markdown

Summary

  • Send periodic SSE comment frames on idle standalone GET streams.
  • Clear the timer when the stream is cancelled or closed by transport cleanup.
  • Add a fake-timer regression test for the first keep-alive frame.

Fixes #1211.

Validation

  • pnpm --filter @modelcontextprotocol/server exec vitest run test/server/streamableHttp.test.ts -t "keep-alive"
  • pnpm --filter @modelcontextprotocol/server exec vitest run test/server/streamableHttp.test.ts
  • pnpm --filter @modelcontextprotocol/server run typecheck
  • pnpm --filter @modelcontextprotocol/server run lint
  • git diff --check

@he-yufeng he-yufeng requested a review from a team as a code owner May 20, 2026 06:58
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 20, 2026

⚠️ No Changeset found

Latest commit: 31e3308

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 20, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2124

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2124

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2124

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2124

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2124

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2124

commit: 31e3308

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.

SSE stream disconnected: TypeError: terminated

1 participant