-
-
Notifications
You must be signed in to change notification settings - Fork 564
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
Race condition when watching dirs leads to missed files #1112
Labels
Comments
Huh, I just spent a couple of hours tracking down the same exact issue. Serves me right for not searching first :) I think I have a fix, a test case is more difficult however due to this being a race. The only sure way to cause the problem is to add that timeout in chokidar code. |
dividedmind
added a commit
to getappmap/chokidar
that referenced
this issue
Jul 8, 2022
Sometimes, when another process just happened to create a file when we were setting up a watch, the new file wouldn't be noticed. To prevent the event not being generated in this case, schedule a directory rescan immediately after setting up a watch. Fixes paulmillr#1112
dividedmind
added a commit
to getappmap/chokidar
that referenced
this issue
Jul 10, 2022
Sometimes, when another process just happened to create a file when we were setting up a watch, the new file wouldn't be noticed. To prevent the event not being generated in this case, schedule a directory rescan immediately after setting up a watch. Fixes paulmillr#1112
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
There is a basic race condition when setting up a watch on a directory, in
nodefs-handler.js
: First the directory contents are scanned, and then afs.watch
watcher is set up. Any file created between those two operations won't be seen, until there's another operation that causes thefs.watch
to trigger and the directory is re-scanned.Versions (please complete the following information):
To Reproduce:
First add this delay, which doesn't cause the race, just makes it a lot easier to trigger.
Then use something like this
Actual output
Events for adding files 1 and 2 don't happen until file 3 is created much later:
Expected output
Events for adding files 1 and 2 should happen right before or after
ready
:The text was updated successfully, but these errors were encountered: