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

🦋 Changeset detected

Latest commit: 7f08da4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/server Patch

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

@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/typescript-sdk/@modelcontextprotocol/client@2124

@modelcontextprotocol/codemod

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

@modelcontextprotocol/server

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

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 7f08da4

@lppedd
Copy link
Copy Markdown

lppedd commented May 26, 2026

This seems to be working in prod. Patched my own library with the changes and all good.

@he-yufeng
Copy link
Copy Markdown
Author

Rebased onto current main, added the server patch changeset, and force-pushed 7f08da4. Local validation: changeset status shows @modelcontextprotocol/server patch; server streamableHttp.test.ts passed with 41 tests; server typecheck and lint passed; git diff --check passed.

@he-yufeng he-yufeng force-pushed the fix/get-sse-keepalive branch from 31e3308 to 7f08da4 Compare May 27, 2026 10:33
@he-yufeng
Copy link
Copy Markdown
Author

Correction: the previous comment was posted after my first push attempt failed in the local pre-push hook with a transient pnpm workspace-state JSON parse error. I reran the push; pre-push typecheck, build, and lint all passed, and 7f08da4 is now pushed.

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

2 participants