Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Two @tanstack/db tests time out under CPU load because a cold module import counts against the 5 s default timeout

Đang mở Phù hợp với người mới
#2,238 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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 evaluation
  • packages/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.ts calls vi.resetModules() and then imports ../src/collection/index.js and ../src/local-only.js.
  • collection-idle-cleanup.test.ts imports ../src/collection/index.js and ../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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TanStack/db

Tất cả issue của TanStack/db

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.