chokidar
chokidar copied to clipboard
Opening a file on macOS triggers a 'change' event
Describe the bug
A clear and concise description of what the bug is.
Versions (please complete the following information):
- Chokidar version 3.5.2
- Node version 12.18.1
- OS version: macOS 12.0.1
Description:
#762 fixes an issue to ignore updates for the access time caused by read operations. I am on macOS and opening a text file still triggers a 'change' event.
To Reproduce:
A double click on a newly created text file updates the following entries (extracted by mdls):
The options for chokidar are these:
{
ignored: /(^|[/\\])\../, // ignore dotfiles
depth: 0,
usePolling: false,
alwaysStat: true,
followSymlinks: false,
ignorePermissionErrors : true,
ignoreInitial: true,
cwd: this.cwd,
awaitWriteFinish : {
stabilityThreshold: 500,
pollInterval: 250
}
We run in to this problem as well.
One interesting note though: This is in an Electron app, and when run in "dev" mode - that is from the Git repo via the bundled Electron binary in node_modules
- the problem occurs. In this case cwd
in the app is /path/to/git-repo/from-where-we-launched
.
When the app is run as a packaged app - i.e. Our Application.app
- the problem does NOT occur. In this case cwd
is always /
regardless from where the app was launched.
Another note: We are watching specific files and no directories.
Okey, so on MacOS when Chokidar is configured with usePolling: false
, MacOS native FSEvents
is used, as we want, in fsevent-handler.js
- rather than nodefs-handler.js
- which doesn't seem to track any previous file stat
so no atime
comparison is being made as described/fixed in #762.
I don't personally have time atm to look deeper into this, but this is the gist of it.
Temporary solution 1: Use polling
- I have not idea what implications this has, if any, on memory and/or CPU consumption though.
Temporary solution 2: Create a thin wrapper yourself in your project that tracks previous stat
and does the atime
comparison "manually".
Same problem here