Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An unhandled exception while Generating ES5 bundles #15493

Closed
ronfogel opened this issue Aug 31, 2019 · 85 comments
Closed

An unhandled exception while Generating ES5 bundles #15493

ronfogel opened this issue Aug 31, 2019 · 85 comments

Comments

@ronfogel
Copy link

🐞 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!

Screen Shot 2019-08-31 at 12 42 29

🔬 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! frontend-mallabee@2.0.1 build-dev: `ng build --configuration dev`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the frontend-mallabee@2.0.1 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
@xawill
Copy link

xawill commented Sep 1, 2019

Same issue here.

@alan-agius4 alan-agius4 added the needs: repro steps We cannot reproduce the issue with the information given label Sep 2, 2019
@alan-agius4
Copy link
Collaborator

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.

@xawill
Copy link

xawill commented Sep 2, 2019

Dear @alan-agius4,

Thank you very much for getting back to us so quickly. Here are my logs :

> OBFUSCATED_PROJECT@0.0.0 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! OBFUSCATED_PROJECT@0.0.0 ng: ng "build"
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the OBFUSCATED_PROJECT@0.0.0 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.

@alan-agius4
Copy link
Collaborator

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.

@alan-agius4 alan-agius4 added area: devkit/build-angular severity5: regression type: bug/fix and removed needs: repro steps We cannot reproduce the issue with the information given labels Sep 2, 2019
@ngbot ngbot bot modified the milestone: needsTriage Sep 2, 2019
@alan-agius4 alan-agius4 added the freq1: low Only reported by a handful of users who observe it rarely label Sep 2, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Sep 2, 2019
@xawill
Copy link

xawill commented Sep 2, 2019

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 ?

@alan-agius4
Copy link
Collaborator

In 8.3 we are using workers farms which will spawn multiple processes at once to parallelize ES5 bundles generation.

@ronfogel
Copy link
Author

ronfogel commented Sep 2, 2019

@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.

@pastcompute
Copy link

pastcompute commented Sep 7, 2019

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]

@pastcompute
Copy link

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

@alan-agius4 alan-agius4 added freq2: medium and removed freq1: low Only reported by a handful of users who observe it rarely labels Sep 10, 2019
@clydin
Copy link
Member

clydin commented Sep 11, 2019

@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.

@daniel-luna-gonzalez
Copy link

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

Thanks it works for me

@josh-m-sharpe
Copy link

@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

@vamcs
Copy link

vamcs commented Sep 17, 2019

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.

@clydin
Copy link
Member

clydin commented Dec 17, 2019

@paullryan Can you open a new issue describing the problem you are encountering? If possible please include the full output of ng version, the build command used, the relevant sections of the configuration file for the used build command (build options & configuration options), and also the console output of the build command with different loading disabled. You should be able to use a temporary browserslist file with only Chrome 75 for the later.

@paullryan
Copy link

paullryan commented Dec 19, 2019

@clydin I realized it was because the prod flag was not being recognized by the build system that was failing so sorry for the the false alarm, thanks for the response but no need for a new issue.

@planet4us
Copy link

Adding this to my package.json solved for me:

"browserslist" : [
    ],

This worked in conjunction with removing the file browserslist

@robelcik
Copy link

Hello. It happened to me after upgrading to angular/cli@8.3.21 and angular-devkit/build-angular@0.803.21. Going back to .20 "fixed" the issue.

@Harika511
Copy link

Hello. It happened to me after upgrading to angular/cli@8.3.21 and angular-devkit/build-angular@0.803.21. Going back to .20 "fixed" the issue.
How to go back to .20. please clarify me

@robelcik
Copy link

@Harika511
In package.json:

  "devDependencies": {
    "@angular-devkit/build-angular": "0.803.20",
    "@angular/cli": "8.3.20",

Note missing "~" or "^" characters.

@strogof
Copy link

strogof commented Dec 20, 2019

@robelcik many many thanks

@schnucks-rrphillips
Copy link

Definetely started hanging on differential loading for me after I ran npm audit fix yesterday, which updated @angular-devkit/build-angular from ^0.802.2 to ^0.803.21. If I roll back to 0.802.2 I can build again. Even 0.803.0 doesn't work.

@mokth
Copy link

mokth commented Dec 23, 2019

i use angular 8.2.10, install latest nodejs solved my problem. no need to change anything :)

@jaime-alex
Copy link

I use angular 8.2.10, upgrade nodejs to v12.14.0 solved my problem.

@bdiriamine
Copy link

run cmd
ionic cordova run android --prod
should work ..
have a good day ;)

@ishfaak
Copy link

ishfaak commented Dec 26, 2019

Hi bdiriamine,

I had so so so much errors and ionic cordova build --release android nothing helped... IONIC Should know (I am using IONIC 5) for the Mobile app to release something hassle free... Your Answer saved me from two days Work.... Thank you so so so much. The Built the APP as you said.

ionic cordova run android --prod

Happy New year Cheers.

Thank you

@PercentageCorporation
Copy link

@Harika511
In package.json:

  "devDependencies": {
    "@angular-devkit/build-angular": "0.803.20",
    "@angular/cli": "8.3.20",

This worked for me also. I also noticed that removing any modules that referenced "ngx-bootstrap" caused the problem to go away.

@SkanderEchaoui
Copy link

SkanderEchaoui commented Dec 30, 2019

Hello. It happened to me after upgrading to angular/cli@8.3.21 and angular-devkit/build-angular@0.803.21. Going back to .20 "fixed" the issue._

thnx mate, this worked for me.

@tmtron
Copy link

tmtron commented Jan 1, 2020

  • using newest node version (12.14.0) didn't work for me
  • solution for now is to go back to old dev-deps:
"devDependencies": {
    "@angular-devkit/build-angular": "0.803.20",
    "@angular/cli": "8.3.20",
  • increasing the memory node --max_old_space_size=12000 also works as a workaround

@schnucks-rrphillips
Copy link

Updating node to 12.14.0 worked for me with the latest build-angular and cli packages. Thanks.

@pkarakal
Copy link

pkarakal commented Jan 3, 2020

After updating to 8.3.21, I also have this issue but only for non production issues. When building with ng build --prod , node doesn't run out of memory. (Using node v12.14.0)

@rocts
Copy link

rocts commented Jan 6, 2020

Same issue for me. Can we get this issue reopened or is there another issue tracking it? This must be affecting most users.

@tmtron
Copy link

tmtron commented Jan 7, 2020

I guess this is related (or even the same): #16515

@dicbrus
Copy link

dicbrus commented Jan 7, 2020

"@angular-devkit/build-angular": "~0.803.21",
"@angular/cli": "^8.3.21",

still happens

@AhsanAyaz
Copy link
Contributor

@dicbrus could you try this?
#16515 (comment)

@jarekcieslak
Copy link

I accidentally stumbled upon this thread. In my case CircleCI was failing because of displaying too much progress in the build step. A small change by running ng build --no-progress helped.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests