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 --prod
Node#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
Community moderators have prevented the ability to post new 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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am getting same issue. How you did this, can you please share your pipeline. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Shanmuga,
Did you find a solution for the error?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A subsequent call did build correctly
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
any resolution for this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there a solution for this? facing the same problem
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.