Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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.

 

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.

 

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?

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?

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.

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

256 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you