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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Bitbucket Pipeline fails with: JavaScript heap out of memory

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

5 votes
Answer accepted

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.

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

 

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.

 

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.

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

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. 

Hello Shanmuga,

 

Did you find a solution for the error?

A subsequent call did build correctly

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.

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.

any resolution for this?

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