Skip to content
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

Prevent EMFILE #10432

Closed
Labels
feature request Issues that request new features to be added to Node.js. fs Issues and PRs related to the fs subsystem / file system.

Comments

@pravdomil
Copy link

pravdomil commented Dec 23, 2016

Try to run (with empty file.txt in working dir):

for(let i = 0; i < 10e3; i++) { require('fs').watch('file.txt') }

Produces instantly: Uncaught Error: watch file.txt EMFILE

It make sense to dedupe multiple watchers on same file to prevent 'too many files open'?

  • Version: v7.2.1
  • Platform: macOS
@mscdex mscdex added feature request Issues that request new features to be added to Node.js. fs Issues and PRs related to the fs subsystem / file system. labels Dec 23, 2016
@fhalde
Copy link
Contributor

fhalde commented Dec 24, 2016

I feel one can always make a wrapper over the fs.watch to do the deduplication. node doing that will restrict/hinder the API users from having multiple watchers for different purposes.

One way to say node to do deduplication yet keeping the API flexible is by adding some new option

@sam-github
Copy link
Contributor

This is not so different from a file open, it uses a fd, and I can't see why you would want to open 1000 watches on the same file.

@bnoordhuis
Copy link
Member

Seems the consensus is that node core isn't the place to fix this. I'll go ahead and close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment