Skip to content
Latchkey

CI "JavaScript heap out of memory" (Node / V8)

V8 hit its heap ceiling and aborted. In CI this usually happens during a large bundle, type-check, or test run that allocates more than the configured (or default) heap.

What this error means

The process prints FATAL ERROR: ... JavaScript heap out of memory and exits. Raising --max-old-space-size or using a larger runner clears it with no source change.

shell
<--- Last few GCs --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0x... node::Abort()

Common causes

The heap limit is below what the build needs

V8 caps old-space memory; large webpack/tsc/test runs can exceed the default and abort.

A genuine memory blowup

Unbounded in-memory accumulation (huge source maps, leaking watchers) can push usage past any reasonable limit.

How to fix it

Raise the V8 heap

Increase the old-space limit, keeping it below the runner RAM.

shell
export NODE_OPTIONS="--max-old-space-size=4096"
npm run build

Reduce memory pressure or use a larger runner

  1. Disable source maps in CI builds where not needed.
  2. Lower test/build worker concurrency.
  3. Move heavy builds to a runner with more RAM if raising the heap is not enough.

How to prevent it

  • Set NODE_OPTIONS=--max-old-space-size relative to runner RAM.
  • Keep CI source-map generation minimal.
  • Right-size runners for large front-end builds.

Frequently asked questions

What causes "JS heap out of memory"?
V8 caps old-space memory; large webpack/tsc/test runs can exceed the default and abort.
How do I fix JS heap out of memory?
Increase the old-space limit, keeping it below the runner RAM.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card