Two @tanstack/db tests time out under CPU load because a cold module import counts against the 5 s default timeout
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue nà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
- 82/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- testing
Hướng nghiên cứu
Đọc packages/db/tests/mutation-id.test.ts và packages/db/tests/collection-idle-cleanup.test.ts, sau đó chạy lệnh Vitest cho hai tệp này từ packages/db dưới tải CPU để xác nhận các timeout. Kiểm tra cách mỗi bài kiểm tra nhập đồ thị mô-đun của Collection và xử lý phần thiết lập; scheduler dọn dẹp khi nhàn rỗi phải được cài đặt trước khi nhập polyfill của nó. Hoàn tất khi cả hai bài kiểm tra đều vượt qua ổn định dưới tải mà không làm yếu các assertions.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Two @tanstack/db tests fail with Test timed out in 5000ms when the machine is busy. They pass when the suite runs alone.
Tests
packages/db/tests/mutation-id.test.ts>mutation ids > do not draw random values during module evaluationpackages/db/tests/collection-idle-cleanup.test.ts>cancels a rescheduled idle cleanup when a subscriber returns
Reproduction
Run the two files while other test processes load the CPU. I ran them while four other vitest run processes ran the full @tanstack/db suite on an 18-core machine:
cd packages/db
npx vitest run tests/mutation-id.test.ts tests/collection-idle-cleanup.test.ts
Result over four runs:
| Run | mutation-id |
collection-idle-cleanup |
|---|---|---|
| 1 | timed out (5005 ms) | timed out (5014 ms) |
| 2 | timed out (5003 ms) | timed out (5004 ms) |
| 3 | timed out (5004 ms) | timed out (5004 ms) |
| 4 | timed out (5004 ms) | passed |
Without the other processes, the full suite passes (285 files, 13,816 tests).
Probable cause
Each test starts with a cold dynamic import() of the Collection module graph inside the test body:
mutation-id.test.tscallsvi.resetModules()and then imports../src/collection/index.jsand../src/local-only.js.collection-idle-cleanup.test.tsimports../src/collection/index.jsand../src/utils/browser-polyfills.js, because it must install its idle scheduler before the polyfill module loads.
The transform and load of that graph count against the test's 5000 ms default timeout. Under CPU load, the import alone can use the full budget. The work after the import takes a few milliseconds, plus an 80 ms wait in the idle-cleanup test.
I did not measure the import time separately, so this cause is probable, not proven.
Effect
- A slow or shared CI runner can fail these tests for no product reason.
- Tools that run the suite in parallel, such as mutation sweeps, record false failures. Both tests made a mutation sweep report every mutant as killed.
Possible fixes
- Give each test an explicit timeout that covers a cold import, for example
30_000. - Or move the import out of the timed test body where the test's isolation requirement allows it. The idle-cleanup test needs its scheduler installed before the polyfill module loads, so its import must stay after that setup.
- Ngôn ngữ chính
- TypeScript
- Star
- 3.9k
- Fork
- 277
- Merge trung bình
- 18 giờ 7 phút
- Pull request đã merge (30 ngày)
- 228
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- 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 TanStack/db
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
[Bug]: REST API URL starting with "http" but no scheme (e.g. httpbin.org/get) is not given an http:// prefixCó thể đã có người làm @ItsDeadlyProgrammer đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
appsmithorg/appsmith#42471 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ehmpathy/rhachet-roles-bhrain#705 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Status: Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
mermaid-js/mermaid#8546 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
braintrustdata/braintrust-sdk-javascript#2659 ·
Maintainer thường phản hồi trong vòng 1 ngày