Closed qarlosalberto closed 2 months ago
It works on the latest (3.6.0) version.
I can confirm it's not working reliable. We use version 3.6.0. Most of the time add/change events don't get fired when they occur immediately after the unlink event. OS: Windows 11.
Tested with following code:
import { dirname } from 'path';
import { existsSync } from 'fs';
import { FSWatcher } from 'chokidar';
import { exit } from 'process';
const handleEvent = (path) => {
console.log('event handled');
};
const fsWatcher = new FSWatcher({
ignorePermissionErrors: true,
ignoreInitial: true,
awaitWriteFinish: {
stabilityThreshold: 1000,
pollInterval: 100,
},
});
fsWatcher.on('all', (eventName, path) => {
console.log(`fired event ${eventName}`);
if (eventName === 'add' || eventName === 'change') {
handleEvent(path);
}
});
const filePath = '/Users/xxx/import/import.txt';
const parentDir = dirname(filePath);
if (!existsSync(parentDir)) {
console.log(`will not start watching ${filePath}. parent directory ${parentDir} does not exist`);
exit(1);
}
fsWatcher.add(filePath);
console.log('watching ' + filePath);
Describe the bug
When I remove a file the
unlink
event is called. After that thechange
event doesn't work when I recreate the fileVersions: