[v2] e2e `protocol:timeout:max-total` is flaky over SSE: fake timers advance before the request reaches the server
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- testing-qa
Direzione di ricerca
Inizia con le varianti SSE di protocol:timeout:max-total in test/e2e/scenarios/protocol.test.ts e confronta i loro passaggi con i timer simulati con il modello vi.waitFor del test timeout:reset-on-progress. Esegui il comando di riproduzione dell’issue, comprese esecuzioni ripetute, per confermare il fallimento intermittente. Il lavoro è completato quando il test raggiunge in modo affidabile gli eventi di avanzamento del server e SSE segnala Maximum total timeout exceeded come gli altri trasporti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 13.6k
- Fork
- 2.5k
- Merge medio
- 1g 2h
- PR unite (30g)
- 51
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelcontextprotocol/typescript-sdk
-
[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)Forse già presa @CloudCorpRecords l’ha presa 2 giorni fa. Apertav1
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
modelcontextprotocol/typescript-sdk#3043 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Stateless 405 response omits the Allow headerForse già presa @Hugo-DDT l’ha presa 8 giorni fa. Apertav2
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
modelcontextprotocol/typescript-sdk#2970 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[v2] @modelcontextprotocol/server inlines fast-uri 3.1.0, which has 9 published advisoriesForse già presa @Andiii208 l’ha presa 10 giorni fa. Apertav2
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
modelcontextprotocol/typescript-sdk#2966 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
v1 v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
modelcontextprotocol/typescript-sdk#2946 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[v2] URI template reserved expansions encode existing %HH sequences againForse già presa @takagibit18 l’ha presa 17 giorni fa. Apertav1 v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
modelcontextprotocol/typescript-sdk#2920 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di modelcontextprotocol/typescript-sdk
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
jessepollak/home#2223 ·
I maintainer di solito rispondono entro 1 giorno
-
grep fixture corpus test follows the corpus's loop symlink under the receipt runner (fails on main)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
code-yeongyu/senpi#3756 ·
I maintainer di solito rispondono entro 1 giorno
-
org:external package:deepagents priority:triage topic:memory topic:middleware type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
langchain-ai/deepagents#7059 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
osmlab/name-suggestion-index#12992 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
hemilabs/ui-monorepo#2506 ·
I maintainer di solito rispondono entro 1 giorno