My 4 GB RAM virtual host has been hitting heap exhaustion when trying to build the Volto 17 (17.1.1 and 17.2.0) frontend image. Along the way other processes (including running Plone+Volto and Emacs) were terminated. I found a workaround that's simple and effective. Here are the details.
tldr: In the frontend package.json
"scripts" "build" line, add "NODE_OPTIONS=--max-old-space-size=2048
, changing the line to:
"build": "NODE_OPTIONS=--max-old-space-size=2048 razzle build --noninteractive",
Details:
You'll know you have the problem if your frontend build-image fails with a stacktrace that includes this:
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
You may also see termination of incidental processes. (Omitting those other processes when building didn't keep my builds from failing.)
Here's the --max-old-space-size
node.js documentation:
Command-line API | Node.js v21.1.0 Documentation (nodejs.org)
I should add that I do have my system configured with some non-trivial additional swap, but that doesn't seem to really help (aside from lengthening the fail time while the system swaps frantically for a while). I tried plugging in various --max-old-space-size
values and 2 GB was by far the best – the build goes smoothly and about as quickly as 16 did, without extraordinary system churn or disruption of other processes. Yay!
I'm curious whether others with systems that have limited memory are also encountering this behavior? If so, hope this info helps!
Ken