Skip to content
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

Change event is fired when file is opened #985

Open
dominicpaul1911 opened this issue Mar 5, 2020 · 12 comments
Open

Change event is fired when file is opened #985

dominicpaul1911 opened this issue Mar 5, 2020 · 12 comments
Labels

Comments

@dominicpaul1911
Copy link

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

@dominicpaul1911 dominicpaul1911 changed the title Change event if fired when file is openned Change event is fired when file is opened Mar 5, 2020
@paulmillr
Copy link
Owner

Opened with what?

@dominicpaul1911
Copy link
Author

Any respective application. For example images with Preview app, movie with Quick time, txt with Sublime etc.

@paulmillr
Copy link
Owner

Could you test this with 3.0 or 3.1?

@dominicpaul1911
Copy link
Author

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.

@paulmillr
Copy link
Owner

Interesting. Our low-level fsevents pkg reports unknown event when a file is opened, but no one reported this.

@pipobscure
Copy link
Contributor

Is it possible that it's reporting an change of atime?

@Listor
Copy link

Listor commented Nov 30, 2020

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 #750 but this is still an issue.

@aspctu
Copy link

aspctu commented Apr 1, 2022

Just ran into this issue today with image files (.png to be specific). It occurs every time I open the file in Preview.

@taratatach
Copy link
Contributor

Yes, it still happens for every kind of opening (even when folders are opened in Finder).

@AlexandreSi
Copy link

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

@marbiano
Copy link

Still an issue in October 2023, anything we can do to help?

@paulmillr
Copy link
Owner

@marbiano unfortunately only a pull req

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants