Merge pull request #201 from davidmonterocrespo24/fix/vitest-forks-toplevel-and-heap

fix(tests): migrate forks config to vitest-4 top-level + restore NODE…
This commit is contained in:
David Montero Crespo 2026-05-19 13:17:53 -03:00 committed by GitHub
commit 2b668d882c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 19 deletions

View File

@ -77,11 +77,16 @@ jobs:
- name: Run tests (shard ${{ matrix.shard }}/2) - name: Run tests (shard ${{ matrix.shard }}/2)
run: cd frontend && npx vitest run --shard ${{ matrix.shard }}/2 run: cd frontend && npx vitest run --shard ${{ matrix.shard }}/2
# Heap is also raised inside the vitest config via env:
# poolOptions.forks.execArgv — forks pool ignores # Belt-and-braces heap raise. The same flag is also set in
# NODE_OPTIONS. With sharding each runner only carries # vitest.config.ts under `forks.execArgv`, but that path was
# ~60 test files' worth of leaked WASM/singleton state # under the now-removed `poolOptions.forks` until the latest
# so the heap stays well under the ceiling. # commit, and we want the workflow not to depend on the
# exact vitest config shape to keep CI green during the
# vitest 4 migration. NODE_OPTIONS gets picked up by the
# parent vitest process; the forks themselves rely on the
# config.
NODE_OPTIONS: --max-old-space-size=8192
# Production build smoke — catches Vite/Rollup-only failures that # Production build smoke — catches Vite/Rollup-only failures that
# vitest doesn't see (chunk wiring, dynamic imports, manualChunks # vitest doesn't see (chunk wiring, dynamic imports, manualChunks

View File

@ -23,20 +23,19 @@ export default defineConfig({
include: ['src/__tests__/**/*.test.ts'], include: ['src/__tests__/**/*.test.ts'],
testTimeout: 30_000, testTimeout: 30_000,
hookTimeout: 30_000, hookTimeout: 30_000,
poolOptions: { // Vitest 4 removed `test.poolOptions` — config moved to top-level
forks: { // `forks` / `threads` / etc. See the deprecation banner the runner
singleFork: false, // emits: "DEPRECATED test.poolOptions was removed in Vitest 4. All
// Vitest 4's forks pool spawns workers with its own execArgv // previous poolOptions are now top-level options."
// and does NOT inherit NODE_OPTIONS from the parent shell, so //
// raising `--max-old-space-size` via the GHA env-var has no // Each forked worker also needs its heap cap raised because the
// effect on the actual worker process. The full suite leaks // suite leaks state across the 117 test files (ngspice WASM ~30 MB
// ngspice WASM modules + singleton state across 117 files and // per init, MixedModeScheduler singleton, zustand stores). Even
// hits Node's 4 GB default at the end of the run ("Worker // sharded (60 files / shard) the leak overflows Node's 4 GB
// exited unexpectedly / Ineffective mark-compacts near heap // default; 8 GB plus sharding fits the runner's 16 GB budget.
// limit"). Bump to 8 GB at the pool level so it actually forks: {
// takes effect. singleFork: false,
execArgv: ['--max-old-space-size=8192'], execArgv: ['--max-old-space-size=8192'],
},
}, },
coverage: { coverage: {
provider: 'v8', provider: 'v8',