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

Reduction to open file counts #102

Merged
merged 1 commit into from
Jun 5, 2012
Merged

Reduction to open file counts #102

merged 1 commit into from
Jun 5, 2012

Conversation

bryankaplan
Copy link

Nodemon was sometimes failing to notice when files changed. After some debugging, I discovered that it was unnecessarily trying to open a vast number of files that exceeded the ulimit maximum. Specifically, the following issues have been fixed:

  1. fs.watch was previously watching files matching .nodemonignore regexes. Listing a file in .nodemonignore only prevented nodemon from restarting, but not from opening the file via fs.watch. This created a potentially enormous number of unnecessarily open files from directories like .git and node_modules. This commit fixes that behavior by filtering out the ignored files before handing them to fs.watch.
  2. fs.watch was previously opening each file each time nodemon restarted, without closing the previously open files. That quickly added up to an enormous number of open files. This commit fixes that behavior by keeping an array of watched files, and only requesting fs.watch for files not already in that array.
  3. The above two conditions went unnoticed because nodemon silently did catch EMFILE errors. A new console.error message has been added to identify when too many files are open for watching. After the first two fixes, such situations should be rare, but in larger projects it's easy to trigger by omitting /.git/ and /node_modules/ from .nodemonignore. Prior to the above two fixes, I was seeing hundreds of caught EMFILE errors each time nodemon restarted.

… no longer attempting to watch the same files multiple times, and outputing error when ulimit is too low.
remy added a commit that referenced this pull request Jun 5, 2012
Reduction to open file counts
@remy remy merged commit d0ba364 into remy:master Jun 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants