Skip to content

Prevent EMFILE #10432

Description

@pravdomil

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

Activity

  1. added
    feature requestIssues requesting new Node.js features.
    fsIssues and PRs related to file-system APIs and the fs module.
    on Dec 23, 2016
  2. fhalde commented on Dec 24, 2016

    @fhalde
    Contributor

    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

  3. sam-github commented on Dec 25, 2016

    @sam-github
    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.

  4. bnoordhuis commented on Jan 10, 2017

    @bnoordhuis
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.fsIssues and PRs related to file-system APIs and the fs module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions