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
Bug: Error: EMFILE: too many open files #18301
Comments
Thanks for the report. Just to verify, are you saying that you didn't get this error with ESLint v8.x but did after upgrading to ESLint v9.0.0? |
@nzakas thank you for the reply. You are right i am not getting the error in ESLint v8.x but getting the error after upgrading to ESLint v9.0.0. |
And just to double-check, you are using the same
Fundamentally, there is no difference between the files that ESLint reads and writes between v8.x and v9.0.0, so this may not be an actual problem with the code. |
@nzakas with v8.x i am using the old legacy config file and with v9.0.0 i am using the new flat config file. EMFILE errors are notoriously difficult to reproduce Can you please try this https://github.com/last-Programmer/eslint-emfile-repro.git repro and you can see that we get the EMFILE error every time when we lint. I have tried only in Windows 11. not quite sure how it behaves in mac os and linux. |
I can get the EMFILE error with your repro on Windows 10. I have an idea of how to address this, will need some time to play around. |
This seems to be related to OS settings and is a very extreme case. Can we add it to the trouble-shooting page to help users to change the OS settings? |
@aladdin-add I don't think changing the OS settings is the correct approach here. I've submitted a PR. |
@nzakas FYI This does not happen in Sonoma Mac OS. |
@aladdin-add Yeah, I don't like We could up the number of files to 10500 in the test to account for the default MacOS limit. I'll also add a test that intentionally fails to verify. |
@nzakas @aladdin-add in my mac i have a project with more than 25000 typescript files and i am not facing any EMFILE errors with flat config. so the limit for mac os is not 10500. i did not remember changing any default settings |
Yes, the actual limit is much higher on Linux systems. It looks like Ubuntu has 65,000+. I've updated the PR to account for that by using the actual descriptor limit on the system. |
For posterity, here's what happened: With eslintrc and the old API, we were reading files in sequentially, one at a time. That meant that large amounts of files could be read easily without running into EMFILE errors because there were never two files being read at the same time. With flat config and the new API, reading is done asynchronously in order not to block on a single file read, and that means we can end up initiating multiple file reads at the same time, leading to the EMFILE error on the same amount of files that the eslintrc API could handle easily. |
* fix: EMFILE errors fixes #18301 * Move catch handler * Add intentional EMFILE failure * Use actual limit on Linux systems in test * Adjust emfile test limit * Fix linting error * Fix test for MacOS * Up MacOS limit in test * Move tmp file output directory * Update .gitignore Co-authored-by: Francesco Trotta <[email protected]> --------- Co-authored-by: Francesco Trotta <[email protected]>
@nzakas @mdjermanovic Thanks for the fix. When this will be released to public npm?. |
We generally publish once every 2 weeks, and the next release can be seen here: #18293 |
This is happening with eslint v8.xx with flat config file also. |
Environment
Environment Info:
Node version: v21.7.2
npm version: v10.5.0
Local ESLint version: v9.0.0 (Currently used)
Global ESLint version: Not found
Operating System: win32 10.0.23606
What parser are you using?
@typescript-eslint/parser
What did you do?
I have migrated my web project to eslint 9 & flat configuration file.
What did you expect to happen?
eslint should complete running without any error
What actually happened?
eslint terminated with reporting the following error.
C:\S\eslint-emfile-repro git:[main]
npm run lint
Oops! Something went wrong! :(
ESLint: 9.0.0
Error: EMFILE: too many open files, open 'C:\S\eslint-emfile-repro\src\file_8367.tsx'
at async open (node:internal/fs/promises:637:25)
at async Object.readFile (node:internal/fs/promises:1246:14)
at async Promise.all (index 8189)
at async ESLint.lintFiles (C:\S\eslint-emfile-repro\node_modules\eslint\lib\eslint\eslint.js:863:25)
at async Object.execute (C:\S\eslint-emfile-repro\node_modules\eslint\lib\cli.js:461:23)
at async main (C:\S\eslint-emfile-repro\node_modules\eslint\bin\eslint.js:165:22)
Link to Minimal Reproducible Example
https://github.com/last-Programmer/eslint-emfile-repro.git
Participation
Additional comments
It is already reported here but was closed #17249
The text was updated successfully, but these errors were encountered: