question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Call and entry last allocation Failed - JS heap out of memory

See original GitHub issue

Description

Recently we included the resin-sdk within our React app, which is causing the npm run build command to emit this error:

> node --max_old_space_size=4096 node_modules/.bin/react-scripts build

Creating an optimized production build...

<--- Last few GCs --->

  130490 ms: Mark-sweep 1260.1 (1434.9) -> 1252.3 (1434.9) MB, 1406.1 / 0.0 ms [allocation failure] [GC in old space requested].
  131817 ms: Mark-sweep 1252.3 (1434.9) -> 1252.3 (1434.9) MB, 1326.8 / 0.0 ms [allocation failure] [GC in old space requested].
  133121 ms: Mark-sweep 1252.3 (1434.9) -> 1256.7 (1404.9) MB, 1303.9 / 0.0 ms [last resort gc].
  134431 ms: Mark-sweep 1256.7 (1404.9) -> 1261.2 (1403.9) MB, 1310.2 / 0.0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3efcb5dcfb51 <JS Object>
    2: _serializeMappings(aka SourceMapGenerator_serializeMappings) [/Users/BioBots/Desktop/biobots-ui/node_modules/uglify-js/node_modules/source-map/lib/source-map-generator.js:~291] [pc=0x34db68761182] (this=0x2e79658e3189 <a SourceMapGenerator with map 0x15785ca99ce9>)
    3: toJSON(aka SourceMapGenerator_toJSON) [/Users/BioBots/Desktop/biobots-ui/node_modules/uglify-js/node_modules/source-m...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/usr/local/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
 4: v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
 5: v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
 6: 0x34db64b079a7
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! biobots-ui2@0.1.0 build: `node --max_old_space_size=4096 node_modules/.bin/react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the biobots-ui2@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

When we removed the resin-sdk from the code, it built just fine, which made me look into increasing the memory allocation. After doing quite a bit of research, I tried increasing the old space size with: node --max_old_space_size=4096 node_modules/.bin/react_scripts build, but based on the output, it seems like the allocated space has not increased.

Expected behavior

Perhaps I’m misunderstanding, or not executing this correctly, but I’d expect that when arguments are passed into the react-script, it takes them into account when executing the build.

Actual behavior

Whether I input extra parameters or not, I end up with the same output error when building production code.

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected): react-scripts@1.0.7
  2. node -v: v6.9.4
  3. npm -v: 5.0.3

Then, specify:

  1. Operating system: Mac OS Sierra V 10.12.15
  2. Browser and version: Safari 10.1.1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:12
  • Comments:35 (18 by maintainers)

github_iconTop GitHub Comments

4reactions
abhisheksdmcommented, Oct 17, 2018

Thanks sourcemap: false in webpack.config.prod.js really worked for me

4reactions
yjb94commented, Jul 25, 2018

export NODE_OPTIONS=--max_old_space_size=4096 this can help…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix JavaScript Heap Out of Memory Error - MakeUseOf
A common problem while working on a JavaScript Node.js project is the “JavaScript heap out of memory” error. This error usually occurs when ......
Read more >
Node.js heap out of memory - javascript - Stack Overflow
Today I ran my script for filesystem indexing to refresh RAID files index and after 4h it crashed with following error:
Read more >
JavaScript heap out of memory - Snyk Support
This generally occurs on larger projects where the default amount of memory allocated by Node (1.5gb) is insufficient to complete the command successfully....
Read more >
How to solve JavaScript heap out of memory error
To fix JavaScript heap out of memory error, you need to add the --max-old-space-size option when running your npm command. ... Alternatively, you ......
Read more >
CALL_AND_RETRY_LAST Allocation failed - JavaScript heap ...
it looks like the issue is coming from should-format when constructing assert messages of very large objects ( and ultimately calling Array.
Read more >

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found