Skip to content

build: raise Node heap for production build - #7

Merged
KarimTamani merged 1 commit into
stackrender:mainfrom
albertoarena:build/build-oom-heap-flag
Aug 4, 2026
Merged

build: raise Node heap for production build#7
KarimTamani merged 1 commit into
stackrender:mainfrom
albertoarena:build/build-oom-heap-flag

Conversation

@albertoarena

Copy link
Copy Markdown
Contributor

Description

npm run build fails with a JavaScript heap out-of-memory error during the "rendering chunks" step, because the app compiles thousands of modules and exceeds V8's default heap ceiling (~2 GB on many machines). The same failure happens inside Docker when the Docker VM has too little RAM.

This PR makes the build succeed out of the box:

  • Set NODE_OPTIONS=--max-old-space-size=8192 on the Vite build step in the build script, via cross-env so it stays portable on Windows.
  • Add cross-env as a devDependency (pinned to ^7.0.3 for broad Node compatibility).
  • Document the matching Docker memory requirement (6-8 GB) in DOCKER.md, since the container build hits the same limit.

Note: --max-old-space-size is a ceiling, not a reservation, so V8 only uses what the build actually needs.

Related Issues

None.

Changes Made

  • Feature implementation
  • Bug fix
  • Documentation update
  • Other (please specify)

Testing

  • Before: npm run build OOMs during "rendering chunks" on a machine whose default V8 heap limit is ~2 GB.
  • After: npm run build completes successfully (verified locally, ~55s) and produces a working dist/.
  • Confirmed cross-env correctly sets NODE_OPTIONS on the build step.

Checklist

Before submitting, please ensure you have:

  • Read the Contributing Guide
  • Followed the Code of Conduct
  • Tested your changes locally
  • Updated documentation if needed

Additional Notes

This is the minimal fix to unblock the build. A follow-up could reduce peak build memory at the source with build.rollupOptions.output.manualChunks in vite.config.ts (the build currently emits a single very large chunk, and Vite already warns about it), which would also allow lowering the heap flag. Happy to open that as a separate PR if of interest.

The production build renders thousands of modules and exceeds V8's
default heap ceiling, so `npm run build` fails with a JavaScript
heap out-of-memory error during "rendering chunks". Set
NODE_OPTIONS=--max-old-space-size=8192 on the Vite build step via
cross-env (kept portable for Windows), so a fresh clone builds
without any manual environment setup. Document the matching Docker
memory requirement in DOCKER.md, since the container build hits the
same limit when the Docker VM has too little RAM.
@KarimTamani
KarimTamani merged commit fab51f2 into stackrender:main Aug 4, 2026
@albertoarena
albertoarena deleted the build/build-oom-heap-flag branch August 4, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants