Repository navigation
Description
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
- Run
pnpm install --frozen-lockfile - Run
pnpm build:all - Run
pnpm --filter @modelcontextprotocol/node test -- test/streamableHttp.test.ts
Observed failures:
should handle batch request messages with SSE stream for responsesreads only thereq-1event and then fails before readingreq-2.should store and replay MCP server tool notificationsreads an earlier{}event and then fails before readingSecond 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:allpnpm --filter @modelcontextprotocol/node test -- test/streamableHttp.test.tspnpm 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.
Activity
test(node): fold remaining single-read and inline read-loop sites int…
Garv978 commentedon Aug 17, 2026
@felixweinberger isnt this already solved in the last pr
Ben-Home commentedon Aug 18, 2026
Fix streamable HTTP SSE tests for Node v26.7.0+ (Fixes modelcontextpr…
mohitchauhan1324325 commentedon Sep 16, 2026
Hi, I’d like to contribute a fix for this issue. I noticed the prepared branch already contains a solution. Would it be okay if I implement the fix and submit a PR based on the same approach?
Parithosh-Varma commentedon Sep 23, 2026
I ported @jstar0's fix to current main with one strengthening (the batch predicate waits for every asserted substring, not just both ids) and verified it:
pnpm --filter @modelcontextprotocol/node test -- test/streamableHttp.test.ts→ 102 passed, prettier clean. Branch: https://github.com/Parithosh-Varma/typescript-sdk/tree/test/sse-chunk-tolerant-2661 (35+/9- inpackages/middleware/node/test/streamableHttp.test.ts).I hit the same fork-PR permissions error as @jstar0 when opening the PR (
CreatePullRequestdenied), so posting here instead — happy for a maintainer to cherry-pick or say the word if the gate lifts and I'll open it.shi-felix commentedon Sep 23, 2026
Hi @jstar0, I’d like to take this issue and carry the fix into an upstream PR. I reproduced both failures on Node 26.7.0, while Node 24 passes. The change updates the two tests to read the SSE stream until the expected event arrives, with a bounded cancellation timeout; no production code changes are involved. I’ll open a PR from my fork shortly.