question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Service worker generation failed: Too many open files" with an assets folder with large number of files

See original GitHub issue

Which @angular/* package(s) are the source of the bug?

service-worker

Is this a regression?

Yes

Description

We recently migrated our large single page application from Angular 9 to Angular 13. Our production build enables the service worker generation, and the "assetsGroups->resources->files " section include “/assets/**” During our first production build on a Windows 10 machine (16GB ram), we received this message:

Service worker generation failed. EMFILE: too many open files,

Our application’s assets folder contains all the dictionaries for at least 13 different languages: every folder cointains at least a thousand files: the service worker generation stops right in the middle. We tried to split the assetsGroups in multiple elements (one for each language folder), but the service worker generation stopped exactly in the same spot.

Next we checked the source code for the assetsGroups generation and the difference between angular 9 and 13. If we are looking in the right source file, from what we saw seems like that the hashing of all assets files is responsible for the error (\node_modules@angular-devkit\build-angular\src\utils\service-worker.js)

Attached to the issue you’ll find a zip with our sample app: (in any case, we merely create a new app with “ng new”, added the angular/service-worker package and the assetsGroup section, and used “ng build --configuration=production”

ang13Test.zip

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

Service worker generation failed: Too many open files

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 13.2.2
Node: 16.14.0
Package Manager: npm 8.4.1
OS: win32 x64

Angular: 13.2.1
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, localize, material, platform-browser
... platform-browser-dynamic, router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1302.2
@angular-devkit/build-angular   13.2.2
@angular-devkit/core            13.2.2
@angular-devkit/schematics      13.2.2
@angular/cli                    13.2.2
@angular/flex-layout            13.0.0-beta.38
@schematics/angular             13.2.2
ng-packagr                      13.2.1
rxjs                            6.5.5
typescript                      4.5.5

Intel I7 4771 3.50Ghz
16GB Ram

Anything else?

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
LucaBrunicommented, Mar 4, 2022

Yes, it does make sense: we used your HashTrackingMockFilesystem and added a single test. Thanks

0reactions
angular-automatic-lock-bot[bot]commented, Apr 8, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix the 'Too Many Open Files' Error in Linux?
To view the current limits, use the ulimit command with the -S (soft) or -H (hard) option and the -n (the maximum number...
Read more >
node and Error: EMFILE, too many open files - Stack Overflow
I used this command to test the number of files that were opened after doing various events in my app. lsof -i -n...
Read more >
Question - Too many open files - Unity Forum
If it loads too many files in too short a time then it overwrites its buffer and crashes! This is obviously trash software...
Read more >
Maximum Number of File Handles Is Set to a Too Small Value ...
The maximum number of file handles is set to a too small value, causing insufficient file handles. Writing files to HDFS is slow...
Read more >
How to prevent a 'Too many open files' error
If you are seeing an error 'Too many open files' then you may need to increase the number of file handles that the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found