You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On some Linux systems, Chokidar will correctly report an immediate "unlink" and then "add" of a file as a "change" event once but then no longer report change events for that file.
Versions (please complete the following information):
Chokidar version: 3.3.1
Node version: 10.7.0 (but also confirmed on Node 12)
OS version: Ubuntu 16.04.4 (in docker container)
To Reproduce:
This problem occurred on our CI in a docker container. To reproduce the problem, you can directly run a test script against our docker image. You need the following two files:
constfs=require('fs');constpath=require('path');constchokidar=require('chokidar');constwait=()=>newPromise(resolve=>setTimeout(resolve,500));constfile=path.resolve('test.txt');fs.writeFileSync(file,'Initial');constevents=[];constwatcher=chokidar.watch([],{ignoreInitial: true,disableGlobbing: true}).on('all',event=>events.push(event)).add(file);returnwait().then(()=>{fs.unlinkSync(file);fs.writeFileSync(file,'First');}).then(wait).then(()=>{console.log('Events after first update (should not be empty):',events);assert.strictEqual(events[0],'change');events.length=0;// Unwatching and adding the file again on any change is a workaround to fix the issue// watcher.unwatch(file);// watcher.add(file);}).then(wait).then(()=>{fs.unlinkSync(file);fs.writeFileSync(file,'Second');}).then(wait).then(()=>{console.log('Events after second update (should not be empty):',events);watcher.close();if(events[0]!=='change'){console.error('Did not receive expected "change" event');process.exit(1);}});
To test, just run npm install and then npm run test-docker. npm test will instead run the test on the local system.
Expected behavior
If a watched file is unlinked and then immediately rewritten, we receive a "change" event (already happens).
If this happens again after some time, another "change" event should be generated (this does NOT happen).
Additional context
This was uncovered while preparing to ship Rollup@2 with bundled chokidar@3. While bundling itself was rather painless, one of our watch test cases was consistently red after the update, hence the issue. We were able to work around this on our side by doing a watcher.unwatch(file); watcher.add(file) as response to any change event but I assume this should not be necessary.
I can confirm from my local system and our CI that the issue occurs neither on MacOS (with or without fsevents) nor on Windows.
See here for more context on the Chokidar integration in Rollup@2: rollup/rollup/#3331
The text was updated successfully, but these errors were encountered:
Describe the bug
On some Linux systems, Chokidar will correctly report an immediate "unlink" and then "add" of a file as a "change" event once but then no longer report change events for that file.
Versions (please complete the following information):
To Reproduce:
This problem occurred on our CI in a docker container. To reproduce the problem, you can directly run a test script against our docker image. You need the following two files:
package.json
test.js
To test, just run
npm install
and thennpm run test-docker
.npm test
will instead run the test on the local system.Expected behavior
If a watched file is unlinked and then immediately rewritten, we receive a "change" event (already happens).
If this happens again after some time, another "change" event should be generated (this does NOT happen).
Additional context
This was uncovered while preparing to ship Rollup@2 with bundled chokidar@3. While bundling itself was rather painless, one of our watch test cases was consistently red after the update, hence the issue. We were able to work around this on our side by doing a
watcher.unwatch(file); watcher.add(file)
as response to anychange
event but I assume this should not be necessary.I can confirm from my local system and our CI that the issue occurs neither on MacOS (with or without fsevents) nor on Windows.
See here for more context on the Chokidar integration in Rollup@2: rollup/rollup/#3331
The text was updated successfully, but these errors were encountered: