[v2] e2e `protocol:timeout:max-total` is flaky over SSE: fake timers advance before the request reaches the server
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- testing-qa
调研方向
从 test/e2e/scenarios/protocol.test.ts 中 protocol:timeout:max-total 的 SSE 变体开始,并将它们的虚拟计时器步骤与 timeout:reset-on-progress 测试的 vi.waitFor 模式进行比较。运行 issue 中的复现命令,包括重复运行,以确认间歇性故障。完成标准是测试能够可靠地到达服务器的进度事件,并且 SSE 像其他传输方式一样报告 Maximum total timeout exceeded。
由索引模型根据 Issue 内容生成。
描述
What happened?
On macOS, the two SSE variants of protocol:timeout:max-total in test/e2e/scenarios/protocol.test.ts fail intermittently on a clean clone of main. The other transports always pass, and CI on main is green.
AssertionError: expected 0 to be greater than or equal to 3
❯ scenarios/protocol.test.ts:713:30
followed by an unhandled SdkError: Request timed out.
The failure rate moves around. On Oct 14 it failed in the full suite and in 3 of 3 isolated runs. On Oct 16, -t "timeout:basic|timeout:max-total" failed 3 of 6 times, while the max-total test on its own passed 6 of 6.
What I think is happening: the test switches to fake timers, starts the call, and immediately advances the clock in 200ms steps. Over SSE, the tools/call request is a real HTTP POST, and the fake clock doesn't wait for it. When the POST is slow to land, the clock is already past the 500ms per-request timeout, so the call rejects with Request timed out before the server sends any progress. In those runs the test never reaches maxTotalTimeout at all.
To check, I added temporary logging of server-sent progress, client-received progress, and each clock step. In failing runs, the server's first progress shows up only after the clock reaches 600ms, by which point the call has already been rejected. Then I added 10ms of real time (a setTimeout captured before useFakeTimers) after each advanceTimersByTimeAsync. With that, all 12 variants passed on 3 of 3 runs, and SSE rejects with Maximum total timeout exceeded after 4 progress ticks, the same as the other transports.
The sleep only confirms the cause; it isn't a fix. protocol:timeout:reset-on-progress already avoids this race by awaiting vi.waitFor(() => expect(received.length).toBeGreaterThanOrEqual(i)) after each step, and max-total has no equivalent. Waiting until the server has received the call before advancing the clock should fix it. One wrinkle: vi.waitFor advances fake timers while it polls, so the wait needs to sit where it can't eat into the timeout budget under test.
Happy to open a test-only PR if that approach sounds right.
What did you expect?
The test passes regardless of machine speed, and actually exercises maxTotalTimeout over SSE.
Code to reproduce
cd test/e2e
pnpm vitest run scenarios/protocol.test.ts -t "timeout:basic|timeout:max-total"
# intermittent, so run it several times
SDK version
main @ 9bc40e90 (macOS / Darwin 27, Node 24.16.0, pnpm 10.26.1)
Area
Transports
- 主要语言
- TypeScript
- 星标
- 13.6k
- 派生
- 2.5k
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 51
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/typescript-sdk 的其他 Issue
-
[v1.x] Backport #2654: `notifications/cancelled` with `requestId: 0` is ignored, so the first server→client request cannot be cancelled (still in 1.32.1)可能已有人在做 @CloudCorpRecords 于 2 天前认领。 未关闭v1
难度 2/5 1-3 小时 新手友好度 77/100
modelcontextprotocol/typescript-sdk#3043 · 1 条评论 ·
维护者通常 1 天内回复
-
Stateless 405 response omits the Allow header可能已有人在做 @Hugo-DDT 于 8 天前认领。 未关闭v2
难度 2/5 1-3 小时 新手友好度 82/100
modelcontextprotocol/typescript-sdk#2970 · 2 条评论 ·
维护者通常 1 天内回复
-
[v2] @modelcontextprotocol/server inlines fast-uri 3.1.0, which has 9 published advisories可能已有人在做 @Andiii208 于 10 天前认领。 未关闭v2
难度 2/5 1-3 小时 新手友好度 72/100
modelcontextprotocol/typescript-sdk#2966 · 3 条评论 ·
维护者通常 1 天内回复
-
v1 v2
难度 2/5 1-3 小时 新手友好度 72/100
modelcontextprotocol/typescript-sdk#2946 · 4 条评论 ·
维护者通常 1 天内回复
-
[v2] URI template reserved expansions encode existing %HH sequences again可能已有人在做 @takagibit18 于 17 天前认领。 未关闭v1 v2
难度 2/5 1-3 小时 新手友好度 84/100
modelcontextprotocol/typescript-sdk#2920 · 1 条评论 ·
维护者通常 1 天内回复
查看 modelcontextprotocol/typescript-sdk 的全部 Issue
相似的 Issue
-
docs(api): openapi.yaml still documents gif-tools optimize colors as 2-256 instead of 2, 4, 16, 256未关闭area: backend documentation priority: low
难度 2/5 1-3 小时 新手友好度 84/100
snapotter-hq/SnapOtter#2919 ·
维护者通常 1 天内回复
-
accepted :+1: bug db/redis
难度 2/5 1-3 小时 新手友好度 76/100
beekeeper-studio/beekeeper-studio#4882 · 1 条评论 ·
维护者通常 1 天内回复
-
ready-for-triage
难度 2/5 1-3 小时 新手友好度 72/100
konflux-ci/konflux-ui#1630 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
ahmedkhaleel2004/gitdiagram#233 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
simkimsia/netlify-axi#19 ·
维护者通常 1 天内回复