-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
fs.watch() doesn't notify content changes starting v10.16.0 #28882
Comments
Thanks for the report. It's a duplicate of #27869 and one or two other issues so I'll go ahead and close this out. I'm afraid a fix is hampered by the fact that it swaps one regression for another, see the linked issues for details. |
@bnoordhuis thanks for the quick response. Nevertheless, I do not understand how this could be a duplication of #27869, as the latter refers to events reported by |
Sorry, I should've explained. The reason the behavior changed is because Node.js / libuv switched to a completely different mechanism for watching files (kqueue vs. fsevents.) |
I see - same root cause for both issues. Nevertheless to me the use case seems different and I'd rather keep it open, but suite yourself: I'll set myself as a watcher on the other issue as well 🙏 |
@bnoordhuis as author of #27869 I am not sure I would agree this issue is related. Yes, the underlying source of the bug is the change of Btw when changing the code to use |
As a side note - which could possibly help readers out: sharing that I've switched to |
fs
In versions
10.16.0
and newer,fs.watch()
does not notifychange
events when watching a specific file -- at least not whenfs.write()
is used in either the running or a different process. Thechange
event is triggered in version10.15.3
and older in such a use case, nevertheless.Simple reproduction code:
watch.js
Watches a file called
test.txt
usingfs.watch()
:write.js
Repeatedly writes text buffers onto
test.txt
:Final output using node
10.16.0
:(i.e. change is only reported when
test.txt
is created and upon fd closing).Final output using node
10.15.3
:(i.e. reported per each write)
Notes:
tail -f test.txt
running simultaneously vividly shows that the writes do take place properly even when the events are not reported byfs.watch()
.echo something >> test.txt
) does trigger a change event in node10.16.0
or higher.The text was updated successfully, but these errors were encountered: