A webpack build hit the V8 heap ceiling and aborted. Large dependency graphs, full source maps, and many parallel loaders push memory past the default heap in CI.
What this error means
The build fails with FATAL ERROR: ... JavaScript heap out of memory during bundling. Raising --max-old-space-size or trimming the build clears it with no config rewrite.
shell
<--- Last few GCs --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
at webpack/lib/Compilation.js
Common causes
Heap limit below the bundle size
Large apps with full source maps can exceed the default V8 heap during a production build.
Too much parallelism in loaders/minifiers
Parallel terser/babel work multiplies peak memory on a memory-tight runner.
How to fix it
Raise the V8 heap
Increase old-space memory below the runner RAM.
shell
NODE_OPTIONS="--max-old-space-size=4096" npx webpack --mode production
Slim the build or use a larger runner
Disable or reduce source maps in CI where not needed.
Cap minifier parallelism (terser-webpack-pluginparallel).
Build on a runner with more RAM for large apps.
How to prevent it
Set NODE_OPTIONS heap relative to runner RAM.
Keep CI source maps minimal.
Right-size runners for large bundles.
Frequently asked questions
What causes "Webpack heap OOM"?
Large apps with full source maps can exceed the default V8 heap during a production build.
How do I fix Webpack heap OOM?
Increase old-space memory 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.