Node "FATAL ERROR: … Allocation failed" in CI - Tune V8 Memory for the Runner
A FATAL ERROR: ... Allocation failed in CI is V8 unable to grow memory for the workload on a constrained runner. Beyond raising the old-space heap, tuning the young-generation semi-space and runner memory together matters in CI.
What this error means
A CI build or test run aborts with FATAL ERROR: ... Allocation failed - JavaScript heap out of memory (or a process-out-of-memory abort). It passes on a beefier machine but fails on the smaller CI runner - a memory-fit problem specific to the runner.
<--- Last few GCs --->
[1:0x...] Mark-Compact ... allocation failure
FATAL ERROR: MarkCompactCollector: young object promotion failed
Allocation failed - JavaScript heap out of memoryCommon causes
The CI runner has less memory than the build needs
A build/test that fits on a developer machine exceeds a small CI runner’s memory, and V8 cannot allocate, aborting fatally.
Defaults not tuned for a high-allocation workload
Workloads that churn many short-lived objects thrash the young generation; the default semi-space and heap sizes are not tuned for the runner, so GC cannot keep up.
How to fix it
Tune V8 for the runner’s memory
Set the old-space heap below runner RAM and enlarge the semi-space for high-allocation builds.
# fit heap under runner memory; widen young-gen for churn-heavy builds
NODE_OPTIONS="--max-old-space-size=3072 --max-semi-space-size=64" npm run build
# in a workflow:
env:
NODE_OPTIONS: --max-old-space-size=3072 --max-semi-space-size=64Cut peak memory and/or size up the runner
- Lower test parallelism and disable CI source maps.
- Split a giant build into smaller workspace builds.
- Move to a runner with more RAM if the workload genuinely needs it.
How to prevent it
- Set NODE_OPTIONS memory flags relative to the runner’s RAM.
- Right-size the CI runner for the heaviest build/test.
- Track build memory so growth is caught before it fails CI.