-
-
Notifications
You must be signed in to change notification settings - Fork 583
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
EBADF error when watching tons of files on macos #1385
Comments
fs.watch with {recursive: true} can be used as backend. That would be breaking change (v5), because it is not available on Linux / IBM until node.js v20. It also comes with following caveats:
It's unclear how to solve issue number one. |
Re no1, I suppose the only way it to test against EPERM errors and stat the filesystem again for the new change, but you won't be able to find out the new name if it's moved I think. Re no2, yeah that's a huge bummer to workaround of. I'm not sure why there's no similar option yet, FWIW @parcel/watcher supports that (as a About Linux / IBM recursive support, I noticed that node manually implemented it on the JS side rather than natively (source 1, source 2), so perhaps there's not much gain using recursive there and what chokidar implements now should be on par perf-wise. |
v4 moved over from our own native Reverting to fsevents usage is a possibility if there's someone trustworthy willing to maintain it. Until then it's a no-go. |
That's fair. Another option is to figure out a workaround on macos, maybe there's a system/bash command that could fix this like linux. |
Just to make sure I understood correctly: the current problem then is because we implement recursive watching ourselves? So with a huge amount of files, we watch each individual one But if we could use node's Maybe we could do some smarts around watching parents or something. Do we know any repos where this problem happens often? Would be good to see what kind of structure we're dealing with in real world |
Yes, but for Unfortunately I haven't found any repros at the moment, but I'm planning to try to create one today. |
Here's a repro and I'm able to reproduce the issue too: https://github.com/bluwy/chokidar-lots-of-files-repro |
Describe the bug
When watching many files on macos. spawning a child process causes EBADF errors consistently. (likely due to reaching maximum file descriptors?)
Versions (please complete the following information):
To Reproduce:
https://github.com/bluwy/chokidar-lots-of-files-repro
Steps:
node gen.js
(generate files in src/ to watch)node test.js
(watches files and tries to run thels
bash command)Expected behavior
EBADF errors should not appear when spawning a child process after watching tons of files.
Additional context
With chokidar v4 removing
fsevents
and usingfs.watch
, this issue is blocking Vite and Nuxt from upgrading to v4 as there's no easy workaround to the problem (other thanusePolling
).unstorage
v1.13.0 that uses chokidar v4)Users have also tried adjusting
ulimit
to extend the maximum file descriptors, but it didn't fix the issue.The text was updated successfully, but these errors were encountered: