FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
The Node process hit V8's heap size limit and crashed. In CI it usually shows up in big builds, TypeScript compiles, or long test runs with many workers.
Published
Why this happens
A large build (webpack, Vite, `tsc`) genuinely needs more heap than Node's default limit allows
Jest or Vitest runs too many workers at once, and together they exhaust the runner's memory
A memory leak in the tests (unclosed servers, global caches, huge snapshot or fixture files) keeps growing across the run
How to fix it
Raise the heap limit for that job: `NODE_OPTIONS=--max-old-space-size=4096` (in MB), staying below the runner's real memory
Limit parallel workers in CI (`jest --maxWorkers=2`, or `--workerIdleMemoryLimit` to recycle workers that grow too large)
If memory keeps climbing over the run, look for the leak with `--logHeapUsage` instead of just raising the limit