[v2] e2e `protocol:timeout:max-total` is flaky over SSE: fake timers advance before the request reaches the server
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- testing-qa
Hướng nghiên cứu
Bắt đầu với các biến thể SSE của protocol:timeout:max-total trong test/e2e/scenarios/protocol.test.ts, rồi so sánh các bước dùng bộ hẹn giờ giả của chúng với mẫu vi.waitFor trong bài kiểm thử timeout:reset-on-progress. Chạy lệnh tái hiện từ issue, bao gồm cả chạy lặp lại, để xác nhận lỗi xảy ra không thường xuyên. Hoàn thành khi bài kiểm thử luôn đạt đến các sự kiện tiến độ của máy chủ và SSE báo cáo Maximum total timeout exceeded như các giao thức truyền tải khác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 13.6k
- Fork
- 2.3k
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 51
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của 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)Có thể đã có người làm @CloudCorpRecords đã nhận 1 ngày trước. Đang mởv1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
modelcontextprotocol/typescript-sdk#3043 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Stateless 405 response omits the Allow headerCó thể đã có người làm @Hugo-DDT đã nhận 7 ngày trước. Đang mởv2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
modelcontextprotocol/typescript-sdk#2970 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[v2] @modelcontextprotocol/server inlines fast-uri 3.1.0, which has 9 published advisoriesCó thể đã có người làm @Andiii208 đã nhận 10 ngày trước. Đang mởv2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelcontextprotocol/typescript-sdk#2966 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelcontextprotocol/typescript-sdk#2946 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[v2] URI template reserved expansions encode existing %HH sequences againCó thể đã có người làm @takagibit18 đã nhận 16 ngày trước. Đang mởv1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
modelcontextprotocol/typescript-sdk#2920 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/typescript-sdk
Issue tương tự
-
"Contains" page watch never matches when its text has a trailing spaceCó thể đã có người làm @RaphaelFakhri đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
CopilotKit/openmuse#184 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
bootstrap-vue-next/bootstrap-vue-next#3357 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[quality] tide.ts: six mutation survivors in the merge-queue gate, draft refusal, fork-403 workflow-file diagnosis and getPull's fork flag are unpinned by any testCó thể đã có người làm @hivecommons-hive đã nhận hôm nay. Đang mởagent/quality needs-kind stage/040-covered-by-pr testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
cncf/prow-github-actions#517 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Unsampled pageload span is profiled when profileLifecycle is 'trace' (browser UI profiling)Có thể đã có người làm @Jxxunnn đã nhận hôm nay. Đang mởBrowser Waiting for: Product Owner
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
getsentry/sentry-javascript#25497 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày