You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fs.watch not emitting file change when file is in use by another app on Windows #36888
Version: v15.5.1 but using 14.15.4 LTS is the same
Platform: Microsoft Windows NT 10.0.17763.0 x64
What steps will reproduce the bug?
Hi! I'm trying to use fs.watch on Windows to check for file change of the latest.log file of Minecraft. On Linux there is no problems, every time using this code it detects file change made by Minecraft and then I can do whatever I want with the file knowing that is has been modified. On Windows, however, it detects file change only when I open it with notepad or right-click it. It never emits a file change when Minecraft writes in it.
How often does it reproduce? Is there a required condition?
When the file is in use by Minecraft/Java.
What is the expected behavior?
Getting logged that the file changed every time 'latest.log' get written to.
What do you see instead?
I'm getting logged that 'latest.log' gets written to only when I open it with notepad or when I right-click it.
Additional information
Using fs.watchFile works ok but I can't use it because of the CPU usage.
On Minecraft startup a file change is detected because the game deletes the latest.log and recreates it. But it should log a file modification each time the game adds a line in the log.
Sorry if this issue represents only the bug using Minecraft but I can't think of another realistic way.
I need to check for the file every .5ms, fs.watchFile and Chokidar only allows up to 1ms checks (need to be an integer). fs.watch can check every .5ms, so this is what I need but it doesn't work on Windows.
This issue has been stale for some time, but more importantly, there is another issue similar to this one with much more details on this topic. With that in mind, I'll close this one in favor of the new one and discussion can continue there.
Activity
GrosSacASac commentedon Jan 14, 2021
Thanks for the report.
In the meantime you could try https://github.com/paulmillr/chokidar
MasterIO02 commentedon Jan 26, 2021
I need to check for the file every .5ms, fs.watchFile and Chokidar only allows up to 1ms checks (need to be an integer). fs.watch can check every .5ms, so this is what I need but it doesn't work on Windows.
jasnell commentedon Mar 5, 2021
Hmm... this could be more of a libuv problem than a Node.js problem... @nodejs/libuv ... any thoughts?
lucassilvas1 commentedon Apr 11, 2024
Any update on this? I'm facing this exact problem right now and want to avoid polling at all costs.
StefanStojanovic commentedon Aug 26, 2024
This issue has been stale for some time, but more importantly, there is another issue similar to this one with much more details on this topic. With that in mind, I'll close this one in favor of the new one and discussion can continue there.