Skip to content

Commit f91dade

Browse files
youhaoweiclaude
andcommitted
test: [YW-266] stabilize native-DB-concurrency test flakes (WsManager + mapping-store)
Two native-DB (PGlite/WASM) test races that ate CI re-runs across unrelated PRs this cycle. Fixed at the mechanism level — no test.retry(), no bare timeout bumps to mask the races. server-core (mapping-store flake): vitest 4.x runs all five server-core test files in parallel forks. Every file spins up PGlite (WASM Postgres), so they cold-start the WASM module simultaneously and contend for file descriptors and memory on a loaded CI runner. The first test in each file — "mapping-store > get returns the record written by set" — was the most frequent victim because it runs before any warm-up query. Serialize the suite (maxWorkers/minWorkers 1) so the files cold-start one at a time. The tests are I/O-bound, so the wall-clock cost is small. client / WsManager (the original report) is fixed in the wystack submodule bump: ws.test.ts leaked ~12 PGlite WASM instances (sync afterEach never closed them), squeezing the 2500ms-sleep no-reconnect tests against the 5s bun timeout. The submodule commit adds a tracked-handle registry drained in an async afterEach plus timeout headroom. See wystack PR for detail. De-flake verified locally, each file run 20x with 0 failures: - server-core mapping-store.test.ts: 20/20 pass - client ws.test.ts (submodule): 20/20 pass NOTE: submodule points at the wystack YW-266 branch commit; re-point to the merged wystack main commit before merging this PR. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d171b92 commit f91dade

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

libs/wystack

packages/server-core/vitest.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,15 @@ export default defineConfig({
1212
// tolerates a slow runner without masking a genuine hang.
1313
testTimeout: 60_000,
1414
include: ["**/*.test.{ts,tsx}"],
15+
// All five test files in this package use PGlite (WASM Postgres). Running
16+
// them in parallel forks causes simultaneous WASM cold-starts that contend
17+
// for file descriptors and memory on a loaded CI runner — the first test in
18+
// each file (mapping-store: "get returns the record written by set") was the
19+
// most common victim because it runs before any warm-up query. Serialising
20+
// to a single fork eliminates the cold-start race at the cost of slightly
21+
// longer wall-clock time (the tests are I/O-bound, not CPU-bound, so the
22+
// loss is small).
23+
maxWorkers: 1,
24+
minWorkers: 1,
1525
},
1626
});

0 commit comments

Comments
 (0)