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
When watching a directory for changes an event is emitted when a watched file is saved, even if there were no changes.
This was reported back in 2018 but was closed: #673
This would be really helpful to fix. It's possible to work around the issue (I intend to) but I think it makes more sense being an option or the default behavior in the library itself.
The reasoning behind the original closure:
Can’t suppress the event. That’s not how these signals work.
You could hold onto before and after stats to see if the size changed (which will be imperfect, but maybe good enough), or you could read and hold onto entire file contents to compare whether any actual changes happened.
You could massively reduce the memory use of this approach by keeping a hash of the files instead. Add them all to a map when they're initialized and only emit the event if the new hash is different.
Versions (please complete the following information):
Chokidar version: 3.5.3
Node version 19.4.0
OS version: Ventura 13.4.1
To Reproduce:
const chokidar = require('chokidar');
const watcher = chokidar.watch('.');
watcher.on('change'), () => console.log('changed!'));
// 'changed!' is logged even if the saved file was not changed
The text was updated successfully, but these errors were encountered:
You could massively reduce the memory use of this approach by keeping a hash of the files instead. Add them all to a map when they're initialized and only emit the event if the new hash is different.
Calculating hash can easily take a few seconds for a large file. If you have 300,000 files, calculating hashes will continue endlessly.
We won't implement it. If you need it, you can do this by yourself, by writing a thin wrapper on top of chokidar.
Describe the bug
When watching a directory for changes an event is emitted when a watched file is saved, even if there were no changes.
This was reported back in 2018 but was closed: #673
This would be really helpful to fix. It's possible to work around the issue (I intend to) but I think it makes more sense being an option or the default behavior in the library itself.
The reasoning behind the original closure:
You could massively reduce the memory use of this approach by keeping a hash of the files instead. Add them all to a map when they're initialized and only emit the event if the new hash is different.
Versions (please complete the following information):
To Reproduce:
The text was updated successfully, but these errors were encountered: