Frontend stopped building with "Reached heap limit Allocation failed - JavaScript heap out of memory" error

Over the last few days, my frontend stopped building with these errors:

#11 213.7 [73:0x702d870]   141768 ms: Scavenge 1588.0 (1979.6) -> 1586.3 (1995.6) MB, 9.4 / 0.0 ms  (average mu = 0.781, current mu = 0.343) allocation failure; 
#11 213.7 [73:0x702d870]   143290 ms: Mark-sweep (reduce) 2069.3 (2467.4) -> 2068.0 (2404.1) MB, 350.3 / 0.0 ms  (+ 3.9 ms in 864 steps since start of marking, biggest step 0.3 ms, walltime since start of marking 1522 ms) (average mu = 0.838, current mu = 0.891) fi
#11 213.7 
#11 213.7 <--- JS stacktrace --->
#11 213.7 
#11 213.7 FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
#11 213.9  1: 0xb95be0 node::Abort() [/usr/local/bin/node]
#11 213.9  2: 0xa9a7f8  [/usr/local/bin/node]
#11 213.9  3: 0xd6f5b0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
#11 213.9  4: 0xd6f957 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
#11 213.9  5: 0xf4ceb5  [/usr/local/bin/node]
#11 213.9  6: 0xf5f38d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
#11 213.9  7: 0xf605da v8::internal::Heap::FinalizeIncrementalMarkingIfComplete(v8::internal::GarbageCollectionReason) [/usr/local/bin/node]

To resolve this, I had to increase Node's max-old-space-size by adding an environment setting to my frontend/Dockerfile.

# syntax=docker/dockerfile:1
ARG VOLTO_VERSION=17.15.2
FROM plone/frontend-builder:${VOLTO_VERSION} as builder
ENV NODE_OPTIONS="--max-old-space-size=8192"
1 Like