Describe the bug
vitest 4.0.18 has a memory leak when running multiple tests in sequence, causing OOM (Out of Memory) errors. Downgrading to 4.0.4 resolves the issue.
Reproduction
The tamagui monorepo has a reproduction of this issue:
Steps to reproduce:
- Clone https://github.com/tamagui/tamagui at commit
3ac968be38 (using vitest ^4.0.18)
- Run
bun install && bun run build:js
- Run
cd code/compiler/static-tests && bun run test:babel:web
- Observe OOM error after running 27 tests
With vitest 4.0.4 (commit 9a8381a175), the same tests pass in ~1 second without any memory issues.
System Info
Node.js v24.3.0
macOS Darwin 25.2.0
vitest 4.0.18 (broken)
vitest 4.0.4 (working)
Used Package Manager
bun
Expected behavior
Tests should run without OOM errors regardless of the number of tests being run.
Actual behavior
After running ~20+ tests, the process runs out of memory and crashes with:
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
Additional context
- This only occurs when running multiple tests in the same session
- Individual tests pass fine
- Memory accumulates across tests, suggesting workers/processes aren't being cleaned up properly
- Adding
--max-old-space-size=8192 or --no-file-parallelism doesn't help
- The issue appeared after upgrading from 4.0.4 to 4.0.18
Validations
Describe the bug
vitest 4.0.18 has a memory leak when running multiple tests in sequence, causing OOM (Out of Memory) errors. Downgrading to 4.0.4 resolves the issue.
Reproduction
The tamagui monorepo has a reproduction of this issue:
Steps to reproduce:
3ac968be38(using vitest ^4.0.18)bun install && bun run build:jscd code/compiler/static-tests && bun run test:babel:webWith vitest 4.0.4 (commit
9a8381a175), the same tests pass in ~1 second without any memory issues.System Info
Used Package Manager
bun
Expected behavior
Tests should run without OOM errors regardless of the number of tests being run.
Actual behavior
After running ~20+ tests, the process runs out of memory and crashes with:
Additional context
--max-old-space-size=8192or--no-file-parallelismdoesn't helpValidations