Two @tanstack/db tests time out under CPU load because a cold module import counts against the 5 s default timeout
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- testing
Research direction
Read packages/db/tests/mutation-id.test.ts and packages/db/tests/collection-idle-cleanup.test.ts, then run the two-file Vitest command from packages/db under CPU load to confirm the timeouts. Check how each test imports the Collection module graph and handles setup; the idle-cleanup scheduler must be installed before its polyfill import. Done when both tests reliably pass under load without weakening their assertions.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- TypeScript
- Stars
- 4k
- Forks
- 277
- Avg merge
- 18h 49m
- Merged PRs (30d)
- 224
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TanStack/db
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
OfflineExecutor.dispose() never settles pendingTransactionPromisesPossibly taken @Claire-ovo claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
TanStack/db#2254 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 1-2 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
Similar issues
-
Add: ON Phim Viet SDOpencheck:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
area:agents area:cost bug platform:macos
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
anthropics/claude-code#105375 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
galaxyproject/loom#616 ·
Maintainers usually reply within 1 day
-
e2e-failure ready-to-code
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
redhat-developer/rhdh-plugin-export-overlays#4580 · 1 comment ·
Maintainers usually reply within 1 day