Skip to content

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

@LucaBruni

Description

@LucaBruni

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: service-workerIssues related to the @angular/service-worker package

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions