An unhandled exception while Generating ES5 bundles
🐞 Bug report
Command (mark with an x)
- [ ] new
- [x ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Is this a regression?
Yes, the previous version in which this bug was not present was 8.2.1, maybe 8.2.2
Description
When using ng build in circle ci, it throws an error (screenshot attached):
Generating ES5 bundles for differential loading...
An unhandled exception occurred: cancel after 1 retries!
🔬 Minimal Reproduction
Unfortunately, I cant provide a way to reproduce it as it happens only in CI and I am unable to get the logs. I think it's related to the size of my app but I cant be sure.
🔥 Exception or Error
WARNING in budgets, maximum exceeded for initial. Budget 2 MB was exceeded by 2.2 MB.
Generating ES5 bundles for differential loading...
An unhandled exception occurred: cancel after 1 retries!
See "/tmp/ng-8Tr7C1/angular-errors.log" for further details.
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] build-dev: `ng build --configuration dev`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] build-dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/circleci/.npm/_logs/2019-08-31T09_20_07_881Z-debug.log
Exited with code 1
🌍 Your Environment
@angular-devkit/architect 0.803.2
@angular-devkit/build-angular 0.803.2
@angular-devkit/build-optimizer 0.803.2
@angular-devkit/build-webpack 0.803.2
@angular-devkit/core 8.3.2
@angular-devkit/schematics 8.3.2
@angular/cdk 8.1.4
@angular/cli 8.3.2
@angular/flex-layout 8.0.0-beta.27
@angular/material 8.1.4
@ngtools/webpack 8.3.2
@schematics/angular 8.3.2
@schematics/update 0.803.2
rxjs 6.5.2
typescript 3.5.3
webpack 4.39.2
Same issue here.
Hi @ronfogel and @xawill, can anyone of you provide the logs please and take it from there?
Most likely though we'd need a minimal repro.
You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.
Dear @alan-agius4,
Thank you very much for getting back to us so quickly. Here are my logs :
> [email protected] ng OBFUSCATED_CI_PATH
> ng "build"
chunk {main} main-es2015.js, main-es2015.js.map (main) 8.59 MB [initial] [rendered]
chunk {polyfills} polyfills-es2015.js, polyfills-es2015.js.map (polyfills) 264 kB [initial] [rendered]
chunk {polyfills-es5} polyfills-es5-es2015.js, polyfills-es5-es2015.js.map (polyfills-es5) 584 kB [initial] [rendered]
chunk {runtime} runtime-es2015.js, runtime-es2015.js.map (runtime) 6.16 kB [entry] [rendered]
chunk {styles} styles-es2015.js, styles-es2015.js.map (styles) 2.09 MB [initial] [rendered]
chunk {vendor} vendor-es2015.js, vendor-es2015.js.map (vendor) 10 MB [initial] [rendered]
Date: 2019-08-27T13:16:27.208Z - Hash: cdbe70565be644ecc800 - Time: 62573ms
Generating ES5 bundles for differential loading...
An unhandled exception occurred: cancel after 1 retries!
See "/tmp/ng-EB7H6h/angular-errors.log" for further details.
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] ng: ng "build"
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] ng script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Here is what is contained in /tmp/ng-EB7H6h/angular-errors.log :
[error] ProcessTerminatedError: cancel after 1 retries! at Farm.
(OBFUSCATED_CI_PATH/node_modules/worker-farm/lib/farm.js:88:25) at Array.forEach ( ) at Farm. (OBFUSCATED_CI_PATH/node_modules/worker-farm/lib/farm.js:82:36) at listOnTimeout (internal/timers.js:531:17) at processTimers (internal/timers.js:475:7)
As a programmer, I totally understand why you need a way to reproduce the problem in order to solve it. Unfortunately I cannot, as it only happens when building in the CI (i.e. it doesn't happen locally even though the setup is identical) and of course I cannot give you access to my CI...
I have no clue how to help you help me for this one... But tell me if you have any idea.
Seeing the full stacktrace it might be a resource problem since CIRCLE CI will have limited resources If you are using the free plan the resources are 2CPU and 4096MB.
It's Atlassian bamboo CI, for me, but I also arrived at the conclusion that it was ressources related. I'll try to tweak the performance parameters of Bamboo. Any particular reason why 8.3.x is more ressource-hungry than <8.3 ?
In 8.3 we are using workers farms which will spawn multiple processes at once to parallelize ES5 bundles generation.
@alan-agius4 Maybe a good way to maintain it (sounds like a good way to improve performance locally) and provide a solution to CI environments with limited resources would be adding an option to angular.json or some other place to determine whether it should run multiple processes to parallelize ES5 bundles generation or not.
This has just started happening to me after Generating ES5 bundles for differential loading... on a Mac Mini with 2.6GHZ i5 and 16GB of RAM latest MacOS 10.14.6 when I build with --debug through Ionic4 (not a CI system), or rather, ng build with no options.
Upgraded from 0.803.2 to 0.803.3 etc and still happens
(I'm not presently in a position to make a minimal repo, sorry)
Generating ES5 bundles for differential loading...
<--- Last few GCs --->
[37943:0x10263e000] 81008 ms: Scavenge 1323.3 (1422.1) -> 1322.6 (1422.6) MB, 5.6 / 0.0 ms (average mu = 0.115, current mu = 0.085) allocation failure
[37943:0x10263e000] 81017 ms: Scavenge 1323.5 (1422.6) -> 1322.8 (1423.1) MB, 6.7 / 0.0 ms (average mu = 0.115, current mu = 0.085) allocation failure
[37943:0x10263e000] 81032 ms: Scavenge 1323.6 (1423.1) -> 1323.0 (1423.6) MB, 11.6 / 0.0 ms (average mu = 0.115, current mu = 0.085) allocation failure
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x2eb0f885be3d]
Security context: 0x29da7771e6e1 <JSObject>
1: SourceMapGenerator_addMapping [0x29daa22a4199] [/redacted/node_modules/@babel/generator/node_modules/source-map/lib/source-map-generator.js:~94] [pc=0x2eb0f8ed8975](this=0x29da67606c49 <SourceMapGenerator map = 0x29dacd3304b9>,aArgs=0x29da105603f1 <Object map = 0x29daef9ee9f1>)
2: argum...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x10003b125 node::Abort() [/usr/local/bin/node]
2: 0x10003b32f node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
3: 0x1001a89a5 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
4: 0x100573dc2 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
5: 0x100576895 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/usr/local/bin/node]
6: 0x10057273f v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
7: 0x100570914 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
8: 0x10057d1ac v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
9: 0x10057d22f v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
10: 0x10054cb74 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
11: 0x1007d4a44 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
I was able to fix my build by for the moment changing the tsconfig.app.json target from es2015 back down to es5, this disabled differential loading.
See https://angular.io/guide/deployment#differential-loading
@pastcompute Can you provide the output just prior to the Generating ES5 bundles for differential loading...? Or more specifically, the sizes of the source map files? Sourcemap processing on node is unfortunately incredibly memory intensive. We've added an alternative source map processing path when the code size is beyond a certain point but the heuristics may need to be adjusted. Any information as to file size or number of source entries within the source maps would be helpful in making improvements in this area.
I was able to fix my build by for the moment changing the
tsconfig.app.jsontargetfromes2015back down toes5, this disabled differential loading.See https://angular.io/guide/deployment#differential-loading
Thanks it works for me
@clydin here ya go:
From CircleCI (failing build): https://gist.github.com/josh-m-sharpe/864bcf6386e467f1f3218829105ff9b3
And filesizes after compiling (successfully) locally: https://gist.github.com/josh-m-sharpe/92fd81d1f8cef6e14ca248e6466383c0
I can reproduce the problem by running ng build locally and I've tried this with CLI versions: 8.3.2, 8.2.2, 8.2.1 and 8.1.1. Our app is exceeding the budget limits of 5MB for the production builds and I have been trying to investigate with webpack-bundle-analyzer what can be removed, so that's why I needed to run ng build --stats-json locally. Right now, the only way this works is by changing the target from es2015 to es5 in tsconfig.json as @pastcompute suggested.
I'm running WSL on Windows.
Same issue here with CircleCI. Targeting es5 instead of es2015 works but it shouldn't be a viable solution.
Yeah, definitely not a viable solution. I changed it to es5 too. I'm planning to lower my bundle size to see if it fixes it, but that can't happen for a while. I wish this could be resolved without a bundle size change.
Bumping my build agents from 2GB to 8GB of RAM fixed this for me. I'm not sure if 4 or 6GB would have worked, didn't have time to spend on investigation today.
Same issue here with 4GB RAM in linux server.
@vikerman is it possible to test your change by installing @angular/cli from master somehow?
Edit: I see this: https://github.com/angular/angular-cli/tree/master/packages/angular/cli#development-hints-for-working-on-angular-cli ... but I think most folks on this thread have issues in a CI env. So installing from master via yarn/npm is probably required to fully test the update.
Snapshot releases for the relevant package can be found here: https://github.com/angular/angular-devkit-build-angular-builds
All the CLI packages have equivalent snapshot repositories as well.
Please note that these should generally only be used for testing as they represent a version in active development.
ng buildrenders a bundle report where ispolyfills-es5-es2015.[hash].jsbut if we open adistfolder there is nopolyfills-es5-es2015.[hash].jsfile.- bundle sizes in the report don't match actual file sizes on the disk, it leads to the
budgetsissue.
npx ng build --prod
chunk {0} runtime-es2015.b948044840398824f16e.js (runtime) 2.83 kB [entry] [rendered]
chunk {1} main-es2015.112ea16b17b5a46676cc.js (main) 40.3 kB [initial] [rendered]
chunk {2} polyfills-es2015.d3e61f0dd2b58e518eca.js (polyfills) 64.3 kB [initial] [rendered]
chunk {3} polyfills-es5-es2015.f8b5a32bf736d11d106f.js (polyfills-es5) 223 kB [initial] [rendered]
chunk {4} styles.09e2c710755c8867a460.css (styles) 0 bytes [initial] [rendered]
chunk {5} vendor-es2015.54fe0f200bb05726020b.js (vendor) 376 kB [initial] [rendered]
Date: 2019-09-26T11:40:10.150Z - Hash: a7854bf899dd1ecaa499 - Time: 16150ms
Generating ES5 bundles for differential loading...
ES5 bundle generation complete.
Dist folder:
26.09.2019 14:40 15 557 3rdpartylicenses.txt
26.09.2019 14:40 948 favicon.ico
26.09.2019 14:40 954 index.html
26.09.2019 13:49 38 186 main-es2015.112ea16b17b5a46676cc.js
26.09.2019 13:49 38 195 main-es5.112ea16b17b5a46676cc.js
26.09.2019 13:46 37 277 polyfills-es2015.d3e61f0dd2b58e518eca.js
26.09.2019 13:46 124 853 polyfills-es5.f8b5a32bf736d11d106f.js
26.09.2019 13:46 1 485 runtime-es2015.b948044840398824f16e.js
26.09.2019 13:46 1 485 runtime-es5.b948044840398824f16e.js
26.09.2019 14:40 0 styles.09e2c710755c8867a460.css
26.09.2019 13:49 232 482 vendor-es2015.54fe0f200bb05726020b.js
26.09.2019 13:49 258 105 vendor-es5.54fe0f200bb05726020b.js
As you can see vendor and polyfills bundle sizes are not correct.