Skip to content

fix(client): clear resumption state on empty SSE event IDs - #2771

Open
znnnnnnn-wil wants to merge 1 commit into
modelcontextprotocol:mainfrom
znnnnnnn-wil:fix/2769-empty-sse-event-id
Open

fix(client): clear resumption state on empty SSE event IDs#2771
znnnnnnn-wil wants to merge 1 commit into
modelcontextprotocol:mainfrom
znnnnnnn-wil:fix/2769-empty-sse-event-id

Conversation

@znnnnnnn-wil

Copy link
Copy Markdown

Summary

Fixes #2769.

An explicitly empty SSE id: is a last-event-ID reset, not an absent ID. The truthy event.id guard currently ignores that reset and reuses the previous token on reconnect.

  • Update the token and call onresumptiontoken('') when the ID is explicitly empty.
  • Clear POST-stream resumability when no usable token remains. Standalone GET streams still reconnect, without Last-Event-ID.
  • Preserve the previous token when an event omits the ID field.
  • Add four regression cases and a client patch changeset.

The tests exercise the real SSE parser through the transport with mocked fetch and fake timers: GET header/callback behavior for empty versus absent IDs, and POST stream termination with an empty ID both with and without an earlier non-empty ID. The original empty-ID regression failed before the fix.

This follows the WHATWG SSE empty-ID semantics. ID-only blocks without a dispatched data event and retry-accounting changes in #2684 are outside this PR's scope.

Verification

On Windows, Node.js 22.19.0:

  • Client tests: 38 files, 881 tests passed (including 73 Streamable HTTP tests).
  • Client typecheck and ESLint: passed.
  • Core and client builds: passed.
  • Changed files formatted with Prettier; package-wide Prettier check passed with --end-of-line auto because the checkout uses Windows line endings.
  • git diff --check: passed.

AI assistance was used for investigation, implementation, tests, and this PR description.

@znnnnnnn-wil
znnnnnnn-wil requested a review from a team as a code owner September 9, 2026 01:13
@changeset-bot

changeset-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bf24200

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

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/client Patch
@modelcontextprotocol/codemod Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server-legacy Patch
@modelcontextprotocol/server Patch
@modelcontextprotocol/core-internal 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

pkg-pr-new Bot commented Sep 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@2771

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@2771

@modelcontextprotocol/server

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

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@2771

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: bf24200

@znnnnnnn-wil

Copy link
Copy Markdown
Author

@felixweinberger Hey Felix, would you mind taking a look at this when you get a chance? It fixes the empty SSE id: resumption case from #2769. All checks are green. Thanks!

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.

[v2] Streamable HTTP client does not clear stale resumption token after an empty SSE id

1 participant