Skip to content

test(e2e): make protocol:timeout:max-total wait for the SSE round trip - #3048

Open
Singmin wants to merge 1 commit into
modelcontextprotocol:mainfrom
Singmin:test/max-total-sse-race
Open

Singmin wants to merge 1 commit into
modelcontextprotocol:mainfrom
Singmin:test/max-total-sse-race

Conversation

@Singmin

@Singmin Singmin commented Oct 18, 2026

Copy link
Copy Markdown

protocol:timeout:max-total turns on fake timers, starts the call, and immediately advances the clock in 200ms steps. Over SSE the tools/call POST is real HTTP, so the clock can cross the 500ms per-request timeout before the request reaches the server. The call then rejects with Request timed out and the test fails on expected 0 to be greater than or equal to 3; maxTotalTimeout is never exercised.

Fix

Wait for the server to enter the tool handler before advancing the clock, then wait for each progress notification to reach the client before the next step. Both waits are plain promise waits, so the SSE stream gets the real time it needs while the fake clock stays put and the maxTotalTimeout budget under test is untouched. The loop also stops as soon as the call settles, so a rejection that lands before the next progress notification cannot hang the test.

Tests

  • Reproduced locally by delaying the POST dispatch in the SSE host by 600ms (temporary patch, not part of this PR). The old test fails 2/2 with expected 0 to be greater than or equal to 3; this one passes 2/2.
  • 10 consecutive runs of both SSE cells: all pass.
  • All 12 transport/spec cells of protocol:timeout:max-total: pass.
  • Full scenarios/protocol.test.ts: 358 passed, 50 expected failures.
  • pnpm --filter @modelcontextprotocol/test-e2e typecheck and lint: pass.

Fixes #3045

The fake clock advanced before the tools/call POST reached the server, so
the per-request timeout fired before any progress notification arrived.
Wait for the server to enter the tool handler, then for each progress
notification to reach the client, before advancing the clock again.
@Singmin
Singmin requested a review from a team as a code owner October 18, 2026 16:28
@changeset-bot

changeset-bot Bot commented Oct 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1f5dc6e

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

pkg-pr-new Bot commented Oct 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/codemod

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

@modelcontextprotocol/core

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

@modelcontextprotocol/server

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

@modelcontextprotocol/server-legacy

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

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 1f5dc6e

@claude claude Bot added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Oct 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v2] e2e protocol:timeout:max-total is flaky over SSE: fake timers advance before the request reaches the server

1 participant