How to fix the following build error in travis-ci: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

npm run build works perfectly when ran locally.

However travis-ci keeps failing remotely and reports the following error every time:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

You can find the full project source code at react-hot-starter

Below is the full stacktrace for the erroneous script:

$ npm run build
> react-hot-starter@0.1.0 build /home/travis/build/mateja176/react-hot-starter
> react-app-rewired build
Creating an optimized production build...
=============
WARNING: You are currently running a version of TypeScript which is not officially supported by typescript-estree.
You may find that it works just fine, or you may not.
SUPPORTED TYPESCRIPT VERSIONS: >=3.2.1 <3.5.0
YOUR TYPESCRIPT VERSION: 3.5.1
Please only submit bug reports when using the officially supported version.
=============
<--- Last few GCs --->
[5608:0x3b3c0c0]   245101 ms: Mark-sweep 1340.9 (1499.9) -> 1340.9 (1499.9) MB, 2567.3 / 0.0 ms  allocation failure GC in old space requested
[5608:0x3b3c0c0]   247168 ms: Mark-sweep 1340.9 (1499.9) -> 1340.9 (1462.9) MB, 2066.0 / 0.0 ms  last resort GC in old space requested
[5608:0x3b3c0c0]   249253 ms: Mark-sweep 1340.9 (1462.9) -> 1340.9 (1458.9) MB, 2084.1 / 0.0 ms  last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x308ac3925891 <JSObject>
    1: /* anonymous */ [/home/travis/build/mateja176/react-hot-starter/node_modules/webpack-sources/node_modules/source-map/lib/source-map-generator.js:~48] [pc=0x8c72146985d](this=0x334130f8c2f1 <JSGlobal Object>,mapping=0xb9561a06929 <Object map = 0x153806e6a799>)
    2: arguments adaptor frame: 3->1
    3: forEach(this=0x3b0e579f49 <JSArray[407127]>)
    4: SourceMapConsumer_eachMapping [/hom...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [node]
 2: 0x8cd14c [node]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
 5: v8::internal::Factory::NewUninitializedFixedArray(int) [node]
 6: 0xd83553 [node]
 7: v8::internal::Runtime_GrowArrayElements(int, v8::internal::Object**, v8::internal::Isolate*) [node]
 8: 0x8c7204842fd
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-hot-starter@0.1.0 build: `react-app-rewired build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the react-hot-starter@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/travis/.npm/_logs/2019-07-28T20_47_44_520Z-debug.log
The command "npm run build" exited with 1.

Hello @mateja176 did you found a solution for this issue?

We are currently experiencing the same and not sure what to do. I have set the --max-old-space-size in the node command, but this still doesn’t work.

Let me know if the issues was fixed, Thanks in advance.

@IreneMarquet I haven’t heard anything back regarding this issue. I’ve also posted a question on stackoverflow, but there’s been no responses so far.

@mateja176 good news! we were able to solve it by including in the before_script in travis file:

  • export NODE_OPTIONS=–max_old_space_size=4096

Give it a try. Depending on how much memory you need you might need to increase it to:

  • export NODE_OPTIONS=–max_old_space_size=8192
1 Like
Imprint