chokidar
chokidar copied to clipboard
Change event is fired when file is opened
Describe the bug Change event is fired when a file is opened.
When watching a folder, opening a file triggers a change event, even though the file has not been modified. Tested it with images, movies, text files etc.
Versions (please complete the following information):
- Chokidar version [e.g. 3.2.1 or commit hash] "chokidar": "^3.3.1"
- Node version [e.g. 12.11.0, ensure you are using the latest node.js] v12.11.1
- OS version: [e.g. Ubuntu 19.04 or MacOS 10.15 or Windows 10] MacOS 10.15.3
const chokidar = require('chokidar')
let TMP_WATCHER = chokidar.watch('/Users/dominic/code/test', {
awaitWriteFinish: {
stabilityThreshold: 2000,
pollInterval: 100
},
alwaysStat: true,
})
TMP_WATCHER.on('add', (file, stats) => {
console.log('add', file)
})
TMP_WATCHER.on('change', (file, stats) => {
console.log('change', file)
})
Expected behavior Should not fire change event unless there is a change in the file
Opened with what?
Any respective application. For example images with Preview app, movie with Quick time, txt with Sublime etc.
Could you test this with 3.0 or 3.1?
So the same behavior in previous versions as well. Digging in further looks like fs.watch has the same issue. Whenever a file opened, it fires a change event.
Interesting. Our low-level fsevents pkg reports unknown event when a file is opened, but no one reported this.
Is it possible that it's reporting an change of atime?
Yeah it is a change of atime but i don't think this is supposed to happen as described in this issue. Somehow it got closed for some reason https://github.com/paulmillr/chokidar/issues/750 but this is still an issue.
Just ran into this issue today with image files (.png to be specific). It occurs every time I open the file in Preview.
Yes, it still happens for every kind of opening (even when folders are opened in Finder).
Just ran into this issue today with image files (.png to be specific). It occurs every time I open the file in Preview.
This is still the case today with version 3.5.3
Still an issue in October 2023, anything we can do to help?
@marbiano unfortunately only a pull req