-
-
Notifications
You must be signed in to change notification settings - Fork 586
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
[feature request] auto-detect network mounts and switch to polling #242
Comments
I think grunt-contrib-watch, like gulp, uses an old version of gaze that relies on polling by default. Falling back to polling is easy, but do you have any ideas about how to automatically detect mounted drives and determine a fallback is necessary (without, for instance, just making assumptions about paths like |
Btw, the need to set usePolling for mounted drives is documented in the README. |
Very good point about watch using an old polling-only version of gaze, I just tried it with a recent version and indeed it doesn't work. I'm aware we should use polling, unfortunately my use case involves using grunt-browserify, which uses watchify, which in turn uses chokidar. I was hoping we could use a fallback method instead of configuration parameters, which may very well be impossible. Currently waiting on two PRs that allow passing an option from |
I'd be happy to implement it if we can find a way to automatically detect mounted paths. |
I don't know of any that doesn't involve
|
Well that's something at least - which I hadn't been aware of. I actually don't understand all the fields in http://nodejs.org/api/fs.html#fs_class_fs_stats - is this kind of thing represented in there in any way? |
Trying to find that out right now... |
Don't think so tbh. |
So any objection to closing this issue? |
So close to a solution... How about making running |
Maybe... |
Simple example, in my docker container
Output:
|
I looked a little more into this, turns out Linux: OS X: |
@nfvs Thanks for figuring that stuff out. I'll see what I can do regarding using it to make chokidar more intelligent. |
I was thinking about this the other day because Watchify refuses to let us use polling or pass options to chokidar so I'm stuck on an old version. :( One solution I was thinking of: what if at startup you initiated two watchers. One with polling, one using fs events. Then wait for an event. If they both catch it, kill the polling watcher. If only the polling watcher picks up the change then the filesystem doesn't support events, so kill that one. To me this seems like the only sure-fire way of determining if events will work. Keep in mind it's not just network mounts that must use polling so using something like |
@blopker actually there is an existing pull request exactly for that. If you don't want to wait, you can use this fork. If you use grunt-browserify, support for passing options to Watchify was also just added. |
Sounds like an invitation for 100 new bugs and problems. But let's keep trying to think of elegant ways to detect that a fallback to polling is needed. |
I'm aware of the fixes (there are many of them), Watchify just needs to add one.
You must be an exceptionally bad coder, my condolences. It's funny you're looking for an 'elegant' solution for a library which is essentially a giant hack in the first place. Hopefully this io.js business will fix the fs module and this library can go away. Anyway, good luck with this. 🍺 |
Yup, I'm an exceptionally bad coder. Go away before my horribleness rubs off on you. |
@blopker race conditions in some cases are indeed very hard to fix. Elan is totally right here. Running two watchers at once would never be a good solution for a problem. Anyway this is not a place to discuss whether someone is a good or bad coder. |
There's no mention of On Linux and OSX: It seems trivial to figure out if the cwd is on one of these mount paths, or am I missing something obvious here? |
@gillesdemey would that also work for symlinks? |
We can resolve symlinks using So I think we can solve this in two steps:
EDIT: I've created a quick proof-of-concept and it works on my vagrant box There's probably lots of room for improvement though. |
A thought that just occurred to me is that rather than solve NFS detection, which would still have holes, a potential solution here would be for chokidar to execute something similar to what it does in the unit tests - quickly write, change, and delete a temp file in the watched directory, listening for the events and switching watch modes if the test fails. This could only become default behavior with a major version bump, but maybe it can first be tried out behind an option in a minor release. Interested in anyone else's thoughts on that idea. |
+1 to the idea above |
In some environments like within a Docker container you have a special filesystem. Moving a file is therefore similar to removing it and adding it back. There is no reliable way to know if the file is the same or not, the 'ino' of the file also changes because the filesystem is virtualised. A way could be to compare the file size and make a hash of it but you can imagine how slow it will be. If anyone could provide a better option I am all ears :-) |
@Xample I'm not sure I understand your point. Seems like what you're saying is more relevant to the discussion about My proposal did not involve moving a file. Just adding it, changing its contents, and deleting it. |
@es128 okay I probably mixed up 2 threads, I thought only computer were able to do so :-) |
I'm still having this issue on a vagrant box. |
@paulmillr Was there a resolution to this issue? |
No, i've closed it because no feedback has been posted for 1.5 yrs. If you want to resolve it, go ahead and submit a PR. Don't want to keep a list of 100 issues that are unpopular. |
Only by passing usePolling=true will chokidar watch for changes inside mounted folders. Could be that this happens with all VM shared folders and not just with docker.
Grunt-contrib-watch (which uses gaze) works, perhaps by falling back to polling automatically, so perhaps finding a way to fallback could be an option too.
The text was updated successfully, but these errors were encountered: