-
-
Notifications
You must be signed in to change notification settings - Fork 579
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
Ensure closing watchers does not affect other watchers #1018
Ensure closing watchers does not affect other watchers #1018
Conversation
If the first watcher that was created gets closed all other watchers will no longer receive events. Ran into this scenario after we upgraded Next.js to use the latest chokidar that came with the latest stable watchpack. With chokidar v2 (which watchpack previously depended on) this test passes fine. Using v3 it stops reporting.
Ran the changes against the full test suite |
Thank you! I’ll be reviewing/merging this in a bit. |
Thanks @paulmillr 🙏 |
Hey @paulmillr, just checking in on this as our Next.js test suite fails a few tests related to this issue. Let me know if there's any changes needed 👍 Thanks! |
New release is coming today |
Awesome! Thanks @paulmillr 🙏 |
Apparently github autocompleted to the wrong Paul (Paul Irish) 🤦 Thanks again @paulmillr 🙏 |
Makes sure the version with this patch is installed: paulmillr/chokidar#1018
* chore: upgrade deps * chore: @hapi/joi * chore: ref paulmillr/chokidar#1018
If the first watcher that was created gets closed all other watchers will no longer receive events.
Ran into this scenario after we upgraded Next.js to use the latest chokidar that came with the latest stable watchpack. With chokidar v2 (which watchpack previously depended on) this test passes fine. Using v3 it stops reporting filesystem events.
So far I've tracked it down to this particular line:
https://github.com/paulmillr/chokidar/blob/master/lib/fsevents-handler.js#L149
Because the part that creates the context is only called on the first watcher the
fsw
variable willalways refer to that first watcher.
const.listeners
cont.listeners.size
instead offsw.closed
The symptoms (only on macOS) would be that webpack did not recompile after introducing an error or after doing a bunch of quick changes to a certain file. With the change in this PR applied the symptoms are no longer there.
The particular reason this surfaces in webpack is that when an error happens the watchers are closed and recreated when a compilation error happens as files/dependencies could have changed in between.