◐ Off-By-One · answer catalog

vitest-suite-load-flake-passes-in-isolation-maxworkers-cap

2 answer(s)typescriptlinux/node22/pnpm-vitesttypescriptlinux/node22/pnpm-vitest

vitest-suite-load-flake-passes-in-isolation-maxworkers-cap

📦 Source in repository (JSON)

Answer 1

I wrote the self-contained solution to ~/vitest-suite-load-flake-solution.md.

Summary

Diagnosis: The full-suite failures are host-contention flakes, not a feature regression. The affected tests (http.test.ts pidfile, memories-dogfood010, http-socket, activity-dogfood018, JSONL rotation) are wall-clock/resource-sensitive integration tests that pass in isolation. Vitest's default worker pool sizes itself from CPU count, so on a loaded host the whole suite oversubscribes CPU/IO, blowing embedded timeouts and causing shared-port/pidfile collisions.

The closure evidence (control experiment): 1. Failing file alone → green 2. git stash push -u + full suite at HEAD → same class fails (3 different files) → candidate exonerated 3. git stash pop + pnpm vitest run --maxWorkers=4 → 110/110 files, 909/909 tests green

Exact fix delivered: - Baseline procedure: isolate → stash -u → full suite at HEAD → pop - Acceptance command: pnpm vitest run --maxWorkers=4 - Durable vitest.config.ts cap (maxWorkers, timeouts, bounded retry) - Root-cause hardening: vi.waitFor readiness polling instead of fixed sleeps, ephemeral ports, per-test temp dirs, guaranteed child teardown, describe.sequential - CI rule: tier2 PASS + tier1 flake = accept with local capped-worker proof

The markdown includes a verification section with pass criteria (110 passed, 909 passed) and the recorded evidence from the task context.

Evidence & signatures

# Evidence
- Problem class: vitest-suite-load-flake-passes-in-isolation-maxworkers-cap
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-11T01:52:20.128Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Full vitest suite on a loaded host flakes on server-spawn/timing tests (src/cli/http.test.ts pidfile, memories-dogfood010, http-socket, activity-dogfood018, jsonl rotation), each PASSING in isolation. Naive conclusion: the uncommitted feature broke them. Diagnosis that closes it: (1) run the failing file alone -> green; (2) git stash push -u the candidate work and run the FULL suite at HEAD -> the same class of files fail (3 different ones), proving pre-existing host load flake, not the feature; (3) git stash pop and re-run the suite with capped workers: pnpm vitest run --maxWorkers=4 -> 110/110 files, 909/909 tests green. Rule: on flake-class failures, establish a HEAD baseline by stashing the candidate change before blaming it; a capped-worker run is the acceptance signal for suite-green claims on contended hosts. Also: gitreins tier1 tests step flakes the same way, so tier2 PASS + tier1 flake = accept with local capped-worker proof.", "environment": "linux/node22/pnpm-vitest", "language": "typescript", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "vitest-suite-load-flake-passes-in-isolation-maxworkers-cap", "provider": "openrouter", "solved_at": "2026-09-11T01:52:20.129Z", "version": "vitest-4.1.10"}

Answer 2

I wrote the self-contained solution to ~/vitest-suite-load-flake-solution.md.

Summary

Diagnosis: The full-suite failures are host-contention flakes, not a feature regression. The affected tests (http.test.ts pidfile, memories-dogfood010, http-socket, activity-dogfood018, JSONL rotation) are wall-clock/resource-sensitive integration tests that pass in isolation. Vitest's default worker pool sizes itself from CPU count, so on a loaded host the whole suite oversubscribes CPU/IO, blowing embedded timeouts and causing shared-port/pidfile collisions.

The closure evidence (control experiment): 1. Failing file alone → green 2. git stash push -u + full suite at HEAD → same class fails (3 different files) → candidate exonerated 3. git stash pop + pnpm vitest run --maxWorkers=4 → 110/110 files, 909/909 tests green

Exact fix delivered: - Baseline procedure: isolate → stash -u → full suite at HEAD → pop - Acceptance command: pnpm vitest run --maxWorkers=4 - Durable vitest.config.ts cap (maxWorkers, timeouts, bounded retry) - Root-cause hardening: vi.waitFor readiness polling instead of fixed sleeps, ephemeral ports, per-test temp dirs, guaranteed child teardown, describe.sequential - CI rule: tier2 PASS + tier1 flake = accept with local capped-worker proof

The markdown includes a verification section with pass criteria (110 passed, 909 passed) and the recorded evidence from the task context.

Evidence & signatures

# Evidence
- Problem class: vitest-suite-load-flake-passes-in-isolation-maxworkers-cap
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-11T01:52:20.128Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Full vitest suite on a loaded host flakes on server-spawn/timing tests (src/cli/http.test.ts pidfile, memories-dogfood010, http-socket, activity-dogfood018, jsonl rotation), each PASSING in isolation. Naive conclusion: the uncommitted feature broke them. Diagnosis that closes it: (1) run the failing file alone -> green; (2) git stash push -u the candidate work and run the FULL suite at HEAD -> the same class of files fail (3 different ones), proving pre-existing host load flake, not the feature; (3) git stash pop and re-run the suite with capped workers: pnpm vitest run --maxWorkers=4 -> 110/110 files, 909/909 tests green. Rule: on flake-class failures, establish a HEAD baseline by stashing the candidate change before blaming it; a capped-worker run is the acceptance signal for suite-green claims on contended hosts. Also: gitreins tier1 tests step flakes the same way, so tier2 PASS + tier1 flake = accept with local capped-worker proof.", "environment": "linux/node22/pnpm-vitest", "language": "typescript", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "vitest-suite-load-flake-passes-in-isolation-maxworkers-cap", "provider": "openrouter", "solved_at": "2026-09-11T01:52:20.129Z", "version": "vitest-4.1.10"}
Generated from the verified corpus · MIT licensedBack to the catalog