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
Is there a version that we can rollback to that does not have this issue?
The build procedure for a 1MB app has became a nightmare.
@jimmykane Reverting to these versions helps me
"@angular-devkit/build-angular": "~0.802.2",
"@angular/cli": "~8.2.2"
@egorkel-da14 thanks so much. Tired of waiting 30+ mins to build an app.
Differential loading was introduced in version 8.0.0. Reverting to 8.2.0 will cause production builds to be longer not shorter as two full builds of the application will be performed if differential loading is enabled. This will be even more pronounced on Windows systems where file access is more costly.
Differential loading is controlled by both the target option within the application’s tsconfig and the browserslist file. The browserslist file should ideally be tailored to the application’s browser support requirements. This allows the CLI to optimize the code/stylesheets and produce the required set of application variants for the application’s target browsers. If only browsers that support ES modules are required then the ES5 variant will not be created. If only an ES5 variant is preferred, the tsconfig target can be set to ES5 and only an ES5 variant will be created.
Thanks for your notes, but in my case I need both builds. So 8.2.0 suits me.
8.3.x would be the preferred version in that case. It is faster than 8.2.x. As an example, an application with 3500 lazy routes (that is not a typo), performs a production build with differential loading using 8.2.2 in ~15.5 minutes. With 8.3.8, that build only takes ~6.5 minutes.
It is also important to note that the new build pipeline can perform the differential loading processing of each output file in parallel using a combination of separate processes and threads (if using Node.js 12+). For applications that leverage lazy loading (a recommended best practice), not only will the end user experience improve but build times will improve as well.
The main problem discussed in this thread is that CI systems have limited resources. So parallelism causes build to fail. That's why we revert to prev version. And I know benefits of the new version.
That's not why its failing. The parallelism adjusts based the executing system. It's failing due to the large size of the main files combined with inefficiencies in the AST traverse processing pipeline of one of the CLI's dependencies which is in the process of being corrected.
Beyond this, as a best practice, lazy loading should be strongly considered when the size of the main file becomes larger than 2MB. As this can greatly affect the initial interactivity time for end-users.
@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
Regarding CircleCI, in my case I pushed the button "Rerun from failed" it solved the problem.
I got same problem with 9.0.0-next.9 version & Gitlab CI
- In my project, main.js file size is 1.8mb
- 9.0.0-next.7 ~ next.9 not work
- In Gitlab CI, i use Node 10.x latest image
- tried to disable sourceMap compile but it doesn't work.
- In local build, it success. Only problem on Gitlab CI
@angular-devkit/architect 0.900.0-next.9
@angular-devkit/build-angular 0.900.0-next.9
@angular-devkit/build-ng-packagr 0.900.0-next.9
@angular-devkit/build-optimizer 0.900.0-next.9
@angular-devkit/build-webpack 0.900.0-next.9
@angular/cli 9.0.0-next.9
@ngtools/webpack 9.0.0-next.9
ng-packagr 5.6.1
typescript 3.5.3
webpack 4.41.0
Adding this to my package.json solved for me:
"browserslist" : [
],
The following package.json dependencies along with Node 12.8.1 worked for me.
{
"@angular-devkit/build-angular": "~0.803.10",
"@angular/cli": "~8.3.10",
}
Also, upgraded to Node 12.12.0 and didn't see a regression.
Fixed - But needs verification.
Angular CLI: 9.0.0-next.12
Node: 10.16.3
OS: darwin x64
Angular: 9.0.0-next.11
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, upgrade
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.900.0-next.11
@angular-devkit/build-angular 0.900.0-next.11
@angular-devkit/build-optimizer 0.900.0-next.11
@angular-devkit/build-webpack 0.900.0-next.11
@angular-devkit/core 9.0.0-next.12
@angular-devkit/schematics 9.0.0-next.12
@angular/cdk 9.0.0-next.0
@angular/cli 9.0.0-next.12
@ngtools/webpack 9.0.0-next.11
@schematics/angular 9.0.0-next.12
@schematics/update 0.900.0-next.12
rxjs 6.5.3
typescript 3.6.4
webpack 4.41.1
I get the same error in small/medium sized project with the config above.
Generating ES5 bundles for differential loading...
An unhandled exception occurred: Call retries were exceeded
The node process memory usage grows until it crashes at 1.4xGb and then it starts all over again for some time.
ng update @angular/cli (updated to 8.3.13) appears to have solved this issue for me
Simply upgrading my Mac Mini Bamboo CI server from Node 10 -> Node 12.10 fixed my builds (cli 8.3.14)
We will spend some time investigating this trying to see if memory usage can be improved.
I tried the latest version again: ng update @angular/cli @angular/core --next but I still get the same error. The good thing is that now it produces some logs and the only thing I can understand from there is that it throws an out of memory exception, at about 2Gb of memory used. How can I help?
I can confirm that it has been fixed inside the latest release.
The latest releases of the CLI contain a variety of improvements to mitigate potential memory issues. However, as Node.js has a default memory limit of 2GB per process, very large projects may still need to increase the memory value for the Node.js process. This can be accomplished via a command similar too the following:
node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build
Note the 4096 value essentially represents a maximum memory usage value for the node process in megabytes. For this example, that would be 4GB of memory. Ensure that the system has enough physical memory to support the value chosen.
It is also recommended to use the latest version of Node 12 (currently 12.13.0) as this contains important improvements related to memory usage.