Two @tanstack/db tests time out under CPU load because a cold module import counts against the 5 s default timeout
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- testing
调研方向
阅读 packages/db/tests/mutation-id.test.ts 和 packages/db/tests/collection-idle-cleanup.test.ts,然后在 CPU 负载下从 packages/db 运行针对这两个文件的 Vitest 命令,以确认超时问题。检查每个测试如何导入 Collection 模块图并处理设置;idle-cleanup scheduler 必须在导入其 polyfill 之前安装。完成标准是两个测试在负载下都能稳定通过,且不削弱其断言。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- TypeScript
- 星标
- 3.9k
- 派生
- 277
- 平均合并
- 18 小时 7 分钟
- 30 天内合并 PR
- 228
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/db 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 4/5 1-2 天 新手友好度 48/100
维护者通常 1 天内回复
-
难度 4/5 1-2 天 新手友好度 48/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
-
难度 4/5 1-2 天 新手友好度 45/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
braintrustdata/braintrust-sdk-javascript#2659 ·
维护者通常 1 天内回复
-
body-parser 2.3.0 in the published ai-dial-chat-bff image is vulnerable (CVE-2026-111181, HIGH)可能已有人在做 @illya-havsiyevych 今天认领。 未关闭bug
难度 1/5 1-3 小时 新手友好度 87/100
epam/ai-dial-chat#9566 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
はさみアイコンを修正する未关闭bug
难度 1/5 1 小时以内 新手友好度 68/100
-
area: core
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复