CI/CD error

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

How to fix it

  1. Raise the heap limit for that job: `NODE_OPTIONS=--max-old-space-size=4096` (in MB), staying below the runner's real memory
  2. Limit parallel workers in CI (`jest --maxWorkers=2`, or `--workerIdleMemoryLimit` to recycle workers that grow too large)
  3. If memory keeps climbing over the run, look for the leak with `--logHeapUsage` instead of just raising the limit

Example


              # GitHub Actions
- name: Build
  run: npm run build
  env:
    NODE_OPTIONS: --max-old-space-size=4096