Skip to content

Streamable HTTP SSE tests assume multiple events share one fetch chunk #2661

Description

@jstar0

Summary

packages/middleware/node/test/streamableHttp.test.ts has tests that call reader.read() once and then assert the accumulated text contains multiple SSE events. On Node v26.7.0, fetch can deliver those SSE events in separate chunks, so the middleware behavior works but the tests fail before reading the later events.

Reproduction

  1. Run pnpm install --frozen-lockfile
  2. Run pnpm build:all
  3. Run pnpm --filter @modelcontextprotocol/node test -- test/streamableHttp.test.ts

Observed failures:

  • should handle batch request messages with SSE stream for responses reads only the req-1 event and then fails before reading req-2.
  • should store and replay MCP server tool notifications reads an earlier {} event and then fails before reading Second notification from MCP server.

Suggested fix

Read from the SSE stream until the expected event text appears or a short timeout/cancel occurs, instead of assuming multiple SSE events share one fetch chunk. I pushed a minimal branch here:
https://github.com/jstar0/typescript-sdk/tree/fix-node-sse-test-chunking-upstream

Verification on that branch

  • pnpm build:all
  • pnpm --filter @modelcontextprotocol/node test -- test/streamableHttp.test.ts
  • pnpm lint:all

Note: GitHub returned a permissions error when I tried opening a fork PR against this repository, so I am filing the reproducible failure with the prepared branch link instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions