Failing to detect file changes after the second save
Describe the bug
When watching a directory, .on('watch', ...); fails to trigger after a file is saved for the second time onwards, but it does properly trigger when saved the first time.
However, .on('raw', ...) does trigger.
Versions (please complete the following information):
- Chokidar version: 4.0.1
- Node version: 18.18.0
- OS version: Windows 11
To Reproduce:
Steps to reproduce the behavior. Include filename and chokidar config.
import chokidar from 'chokidar';
const watcher = chokidar.watch(
"some/dir",
{
ignoreInitial: true,
awaitWriteFinish: true,
cwd: "some/dir",
usePolling: true // Tried this with false and true, didnt impact behavior
}
);
watcher.on('change', onChange);
watcher.on('raw', onRaw);
onChange(fileName: string) {
console.log(`Chokidar: file changed - filename:"${fileName}"`);
}
onRaw(e: string, fileName: string) {
console.log(`Chokidar: raw - event:"${e}", filename:"${fileName}"`);
}Then have a file in some/dir, open and edit it, make a change and save, then make a change and save again.
Expected behavior
Both onChange and onRaw trigger twice, with onRaw logging a "change" event specifically each time
Actual Behavior
Both onChange and onRaw trigger as expected on the first modification+save.
On the second modification+save, only onRaw triggers logging a "change" event, but no matching onChange event is triggered.
Additional context This is specifically being observed with Adobe Acrobat editing a pdf, but I believe the issue is present for any type of file and editor on windows 11. I havent tested other OS/Editor/Filetype options yet.
Source: paulmillr/chokidar