[BUG] "EMFILE: too many open files, open" on boot
Bug Report Quick Checklist
- I am on the latest version of Snowpack & all plugins.
- I use package manager yarn (Fill in: npm, yarn, pnpm, etc).
- I run Snowpack on OS mac (Fill in: Windows, Mac, Linux, etc).
- I run Snowpack on Node.js v12+
Describe the bug
Originally found when using snowpack 3.1.2.
Trying to narrow this down, the error is present in 3.1.0-pre.14, but goes away when using 3.1.0-pre.13.
I've got a large application that I'm porting to snowpack (alas no easy reproduction here).
When running snowpack for the first time after deleting my snowpack cache at node_modules/.cache/snowpack I get the following error that complains about too many open file handles. This occurs before any package building output is shown:
~/s/g/S/web ❯❯❯ rm -rf node_modules/.cache/snowpack/ && yarn run snowpack dev
yarn run v1.22.5
$ snowpack dev
[15:37:19] [snowpack] Welcome to Snowpack! Because this is your first time running
this project, Snowpack needs to prepare your dependencies. This is a one-time step
and the results will be cached for the lifetime of your project. Please wait...
[15:37:20] [snowpack] EMFILE: too many open files, open '/Users/ben/web/app/sections/Collections/CollectionList/components/BulkActionModals/translations/tr.json'
error Command failed with exit code 1.Running ulimit -n // launchctl limit maxfiles suggests I have a soft limit of 256 file descriptors (as far as I know this is the machine's default, I don't believe I've modified this), and running lsof -i -n -P | wc -l suggests I am using 52 of them before snowpack boots.
~/s/g/S/web ❯❯❯ ulimit -n
256
~/s/g/S/web ❯❯❯ launchctl limit maxfiles
maxfiles 256 unlimited
~/s/g/S/web ❯❯❯ lsof -i -n -P | wc -l
52https://wilsonmar.github.io/maximum-limits/ has some suggestions on how to bump the limit for myself. But snowpack should be able to handle this limit gracefully.
https://www.npmjs.com/package/graceful-fs suggets that it may be able to catch and retry these EMFILE errors but I've not played with that myself.
To Reproduce
Sorry. I can reproduce this reliably locally in my private source but I've not got a public reproduction.
I expect this will need a chonky app, and artificially lowering your max file descriptors limit to reproduce.
Expected behavior
Snowpack boots up successfully
Source: FredKSchott/snowpack