Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket Pipeline fails with: JavaScript heap out of memory

ykgh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 20, 2018

I'm trying to run a build of an Angular template app I bought. I have setup the pipeline as follows:

 

image: gabrielaraujof/angular-cli

pipelines:
  default:
    - step:
        script: 
          - npm install
          - ng build --prod
          - tar -zcvf package.tar.gz dist/
          - curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"package.tar.gz"

Now this actually works fine.

 

However when I add the (for me required) `--prod` flag the process ends with some "Javascript heap out of memory" exception (see below for full trace).

Now I haven't changed any parts of the template yet. Does this mean Bitbucket Pipelines cannot build this project or should I keep trying until there is enough memory?

(i only have 9 build minutes left from the trial as this last failed build took over 19 minutes..)

 

+ ng build --prodNode#moveTo was deprecated. Use Container#append.FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory<--- Last few GCs ---> 1005609 ms: Mark-sweep 1242.3 (1436.1) -> 1240.0 (1436.1) MB, 1286.9 / 0.0 ms [allocation failure] [GC in old space requested]. 1006856 ms: Mark-sweep 1240.0 (1436.1) -> 1240.0 (1436.1) MB, 1246.2 / 0.0 ms [allocation failure] [GC in old space requested]. 1008173 ms: Mark-sweep 1240.0 (1436.1) -> 1243.9 (1405.1) MB, 1316.9 / 0.0 ms [last resort gc]. 1009519 ms: Mark-sweep 1243.9 (1405.1) -> 1247.4 (1405.1) MB, 1345.7 / 0.0 ms [last resort gc].<--- JS stacktrace --->==== JS stack trace =========================================Security context: 0x3d2ff4dcfb39 <JS Object> 2: optimize [0x3d2ff4d04381 <undefined>:7677] [pc=0x5fb70f6fef4] (this=0x122106af21e1 <an AST_Binary with map 0x148311e48989>,compressor=0x29f327c5ccc1 <a Compressor with map 0x32d0952754e1>) 3: before [0x3d2ff4d04381 <undefined>:~7640] [pc=0x5fb70e087fa] (this=0x29f327c5ccc1 <a Compressor with map 0x32d0952754e1>,node=0x122106af21e1 <an AST_Binary with map 0x148311e48989>,descend=0x3f6... 1: node::Abort() [@angular/cli] 2: 0x109bf8c [@angular/cli] 3: v8::Utils::ReportApiFailure(char const*, char const*) [@angular/cli] 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [@angular/cli] 5: v8::internal::Factory::NewCode(v8::internal::CodeDesc const&, unsigned int, v8::internal::Handle<v8::internal::Object>, bool, bool, int, bool) [@angular/cli] 6: v8::internal::CodeGenerator::MakeCodeEpilogue(v8::internal::MacroAssembler*, v8::internal::CompilationInfo*) [@angular/cli] 7: v8::internal::FullCodeGenerator::MakeCode(v8::internal::CompilationInfo*) [@angular/cli] 8: 0xb4c51e [@angular/cli] 9: 0xb4e900 [@angular/cli]10: 0xb55fc6 [@angular/cli]11: v8::internal::Compiler::Compile(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ClearExceptionFlag) [@angular/cli]12: v8::internal::Runtime_CompileLazy(int, v8::internal::Object**, v8::internal::Isolate*) [@angular/cli]13: 0x5fb59e092a7

 

6 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

7 votes
Answer accepted
Fernando Buccella
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 19, 2020

By default the memory limit in Node.js is 512 mb.

To solve this issue you need to increase the memory limit by adding the following line to your step script:

script:
- export NODE_OPTIONS=--max_old_space_size=3072

 Note that the memory limit was set to 3gb, but that number is up to you. By default pipelines containers have 4gb.

2 votes
Anthony Xiques
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 26, 2021

It looks like the correct line to add is:

- export NODE_OPTIONS=--max-old-space-size=3072

You can change 3072 to 6144 if you enable the 2x size in your pipeline settings.

Note the dashes in max-old-space-size instead of max_old_space_size mentioned in previous comments.

Official docs: https://nodejs.org/api/cli.html#cli_max_old_space_size_size_in_megabytes

2 votes
alan_bugeja
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 2, 2020

 

Anyone found any fix for this ? I am getting this error as well. I have tried the following:

-max_old_space_size= (tried, 4gb, 8gb, 10gb)

and

bitbuket pipelines yml file

All steps have 2x size set for 8gb and even I have found and tried the options before the steps definitions
options:  
 size: 2x

Sometimes the error still happens, re running the pipeline will work randomly.

 

0 votes
alan_bugeja
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 14, 2020

Guys,

In my case it was wrong configuration in my bitbucket pipelines I had the following option set

services:
  docker:
    memory: 5120

 

Thinking that this would allow more memory in fact it was on the contrary this was allocating 5GB to the docker container and leaving 3GB for the build container, I removed the setting which allocates 1GB for docker container and remaining for build container thus my build now never fails with javascript heap out of memory.

Mahesh Yadav
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 13, 2021

I am getting same issue. How you did this, can you please share your pipeline. Thanks.

0 votes
Shanmuga.Mahalingam
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 6, 2020

I have set the following,

size: 2x script: - export NODE_OPTIONS=--max_old_space_size=7072

and i am still seeing FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory

 

Any help would be appreciated. 

Rodrigo Espinoza
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 13, 2020

Hello Shanmuga,

 

Did you find a solution for the error?

0 votes
ykgh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 24, 2018

A subsequent call did build correctly

raschidjfr
Contributor
November 12, 2019

I’ve got he same issue when NOT adding `—prod`. It use to build in a second or even third run, but now it just doesn’t anymore.

raschidjfr
Contributor
November 13, 2019

Update: I thought of increasing the step size but it is already at 2x. I doubt 8gb are not enough for building a medium-sized angular project.

Frantzdy Romain
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 11, 2019

any resolution for this?

Priyadarshiniy Rajendran
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 26, 2022

Is there a solution for this? facing the same problem

Like Filip Kudla likes this

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events