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.

JavaScript heap out of memory

See original GitHub issue

This is a Bug Report

Description

Endless recursive file loading exceeds process memory limits.

When trying to remove the serverless.yml here: https://github.com/Nordstrom/hello-retail/tree/master/web

With the command (STAGE is properly defined and references an existing stack):

../node_modules/.bin/sls remove -s $STAGE -v
  • What went wrong?
<--- Last few GCs --->

[22378:0x102804600]   192582 ms: Mark-sweep 1484.5 (1567.0) -> 1484.5 (1567.0) MB, 2065.8 / 0.0 ms  allocation failure GC in old space requested
[22378:0x102804600]   194638 ms: Mark-sweep 1484.5 (1567.0) -> 1484.4 (1536.0) MB, 2056.4 / 0.0 ms  last resort gc 
[22378:0x102804600]   196780 ms: Mark-sweep 1484.4 (1536.0) -> 1484.4 (1536.0) MB, 2141.0 / 0.0 ms  last resort gc 


<--- JS stacktrace --->

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

    2: arguments adaptor frame: 1->2
Security context: 0x90122ec0d31 <JS Object>
    3: _settlePromiseFromHandler [<src-root>/hello-retail/node_modules/serverless/node_modules/bluebird/js/release/promise.js:~496] [pc=0x20e01cfbd1f3](this=0x2d4a7d8ea59 <a Promise with map 0x17140f73cc21>,handler=0x2d4a7d97671 <JS Function getValueFromSource.then.valueToPopulate (SharedFunctionInfo 0x2b325a77f011)>,receiver=0x90122e04311 <undefined>,val...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [~/.nvm/versions/node/v7.2.0/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [~/.nvm/versions/node/v7.2.0/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [~/.nvm/versions/node/v7.2.0/bin/node]
 4: v8::internal::Factory::NewByteArray(int, v8::internal::PretenureFlag) [~/.nvm/versions/node/v7.2.0/bin/node]
 5: v8::internal::SourcePositionTableBuilder::ToSourcePositionTable(v8::internal::Isolate*, v8::internal::Handle<v8::internal::AbstractCode>) [~/.nvm/versions/node/v7.2.0/bin/node]
 6: v8::internal::FullCodeGenerator::MakeCode(v8::internal::CompilationInfo*) [~/.nvm/versions/node/v7.2.0/bin/node]
 7: v8::internal::(anonymous namespace)::GenerateUnoptimizedCode(v8::internal::CompilationInfo*) [~/.nvm/versions/node/v7.2.0/bin/node]
 8: v8::internal::(anonymous namespace)::GetUnoptimizedCode(v8::internal::CompilationInfo*) [~/.nvm/versions/node/v7.2.0/bin/node]
 9: v8::internal::Compiler::Compile(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ClearExceptionFlag) [~/.nvm/versions/node/v7.2.0/bin/node]
10: v8::internal::Runtime_CompileLazy(int, v8::internal::Object**, v8::internal::Isolate*) [~/.nvm/versions/node/v7.2.0/bin/node]
11: 0x20e01ca063a7
12: 0x20e01ca0675a
13: 0x20e01ca07e55
14: 0x20e01cfbd1f3
15: 0x20e01cfe1eb4
Abort trap: 6
  • What did you expect should have happened?

Expected: removal of stack

Downgrading to serverless@1.11.0 allowed this to proceed as expected.

  • What was the config you used?

https://github.com/Nordstrom/hello-retail/blob/master/web/serverless.yml

  • What stacktrace or error message from your provider did you see?

see above.

Additional Data

I suspect that this change may have introduced the new behavior but am not certain: https://github.com/serverless/serverless/commit/971a27994c3566d9904f166a2e943c21ba4dfe54#diff-b921cbcedd2151d24391fb39acb84adeR88

  • Serverless Framework Version you’re using: 1.13.2, 1.14.0
  • Operating System: osx
  • Stack Trace: see above
  • Provider Error messages: n/a

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:21
  • Comments:24 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
erikeriksoncommented, Aug 23, 2017

I have been able to validate this fix plus a small delta (#4146) as resolving the matter for both the entirety of Hello, Retail! as well as our latest internal project that was also subject to the problem. Thanks @eahefnawy!

1reaction
HyperBraincommented, Jan 31, 2018

@dashmug You can check the comments in https://github.com/serverless-heaven/serverless-webpack/issues/299. There has been a lengthy discussion of people facing the TypeScript memory problem and I remember there was some workaround that did the job.

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 - Stack Overflow
I have a 64-bit CPU and I've installed x86 node version, which caused the CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory ......
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 >
JavaScript Heap Out Of Memory Error - OpenReplay Blog
A quick solution that you can use to fix "Heap Out Of Memory Error" in JavaScript. We lay out the causes and how...
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 >

github_iconTop Related Medium Post

No results found

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