fabiospampinato/watcher

Opening a file triggers change

Closed this issue · 1 comments

new Watcher('/xy', { recursive: true }, () => console.log('change'));

On Windows 11, watching a directory like this is triggering a 'change' event whenever a file is opened (clicked in solution) in Jetbrains Rider.

Does somebody know something about this behaviour?

Thanks for any help.

I guess your editor is modifying metadata on the opened file (like updating the atime header or something), which causes a change to be detected, which the library processes as a "change" event, since in order to be able to skip this event it would need to keep the old content of the file in memory, read the new content, and match the two, more or less, which is too expensive. You could do that in your code if you need that level of precision.