Symptom
Your activity fails during the build, with an error similar to this:
> cross-env NODE_ENV=production front-commerce build
WEBPACK Compiling client...
WEBPACK Compiling server...
WEBPACK Your client was compiled successfully. Hooray!
W:
W: <--- Last few GCs --->
W:
W: [617:0x4e90960] 163898 ms: Mark-sweep 953.2 (1115.1) -> 833.2 (980.3) MB, 871.1 / 0.1 ms (average mu = 0.813, current mu = 0.330) allocation failure scavenge might not succeed
W: [617:0x4e90960] 164741 ms: Scavenge 844.8 (985.3) -> 834.4 (982.3) MB, 1.2 / 0.0 ms (average mu = 0.813, current mu = 0.330) allocation failure
W:
W:
W: <--- JS stacktrace --->
W:
W: FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
W: 1: 0xa389b0 node::Abort() [node]
// ........
// .......
v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>) [node]
W: 28: 0xc63f5f v8::internal::Builtin_JsonStringify(int, unsigned long*, v8::internal::Isolate*) [node]
W: 29: 0x1446459 [node]
FRONT-COMMERCE got signal SIGABRT, exiting
W: npm ERR! code ELIFECYCLE
W: npm ERR! errno 1
Cause
Front-Commerce Cloud defines a default value that matches the available build container memory size (2Gb), so that node's garbage collection restricts memory consumption of the build process.
Solution
Override the build time environment variable by defining a bigger value. You can use a value between 2048
and 4096
.
Variable name:
env:NODE_OPTIONS
Visible in build: yes
Visible at runtime: no
Value:
--max_old_space_size=3536
Note: it requires Front-Commerce Cloud 2.3.0+