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

All dirs in the watch dir are opened, easily causing too many open files #23

Open
nicolasartman opened this issue Aug 5, 2014 · 4 comments

Comments

@nicolasartman
Copy link

I noticed from #3 that there's a deliberate design decision to watch all dirs in case any new files appear that might match the glob. I can see why this would be helpful in some cases, but it breaks things in others, so a choice would be excellent.

var sane = require('sane');
// Wouldn't actually watch anything, but will crash immediately
sane('/Users/nick/', ['**/fdjsaiofjidosafjioadsfjidosa*']);

As far as I can tell, there's no reasonable way to prevent that from crashing, because there are simply too many dirs opened for watching at once (even with a massive ulimit increase).

My request is that a flag be added to make only files matching the glob on startup get watched. My core use case is for fb-flo, where I want to watch projectdir/static/minified/js/**/*.js and projectdir/static/templates/**/*.html, but there are simply too many dirs under projectdir/static to open them all at once.

Thanks!

@matthewmueller
Copy link

+1

@DavidSouther
Copy link

@nicolasartman I understand where you're going and agree that it's a useful feature, though why don't you have two watches, one for each glob?

@amasad
Copy link
Owner

amasad commented Jan 9, 2015

I thought I'd replied here, must've been another thread. If sane where to predict what could be watched or not, it needs a much deeper understanding of globs, which is probably doable.

Are you actively hitting this problem?
I personally haven't seen a problem with this on OSX and linux with a lot of watched dirs.

Also have you looked into the WatchmanWatcher, I recommend it for larger projects because there is no way to prevent #25

@stefanpenner
Copy link
Collaborator

@amasad if Im understanding this correctly, basically if we made watch(dir) aware of globing, specifically partial globs, we could avoid watching directories who's containing files/directories couldn't possible match. Correct?

I did something I believe is the same with minimatch to ensure node-walk-sync wouldn't traverse directories it should not traverse.

I'll try and poke around sometime, and see if micromatch exposes similar capability.

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

No branches or pull requests

5 participants