Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

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

Ouverte Adaptée aux débutants
#3,045 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@Singmin y travaille déjà.

Depuis le 18/10/2026.

  • #3048 par @Singmin — ouverte

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
72/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
typescript
Domaine
testing-qa

Piste de recherche

Commencez par les variantes SSE de protocol:timeout:max-total dans test/e2e/scenarios/protocol.test.ts, et comparez leurs étapes avec des timers factices au modèle vi.waitFor du test timeout:reset-on-progress. Exécutez la commande de reproduction de l’issue, y compris plusieurs exécutions, pour confirmer l’échec intermittent. Le travail est terminé lorsque le test atteint de manière fiable les événements de progression du serveur et que SSE signale Maximum total timeout exceeded comme les autres transports.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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

Langage dominant
TypeScript
Étoiles
13.6k
Forks
2.5k
Merge moyen
1 j 2 h
PR mergées (30 j)
53

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de modelcontextprotocol/typescript-sdk

Toutes les issues de modelcontextprotocol/typescript-sdk

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.