Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#3,045 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Singmin がすでに取り組んでいます。

2026年10月18日 から。

  • #3048 @Singmin による — オープン

評価

難易度
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 の本文から書いたものです。

説明

v1 v2
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.3k
平均マージ
1日 2時間
マージ済み PR(30日)
51

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/typescript-sdk のほかの issue

modelcontextprotocol/typescript-sdk の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。