chokidar icon indicating copy to clipboard operation
chokidar copied to clipboard

Chokidar does `addDir` and immediately `unlinkDir` for root folder when watching drive root in Windows

Open CxRes opened this issue 9 years ago • 5 comments

Another Windows specific bug...

If I try to watch say C:\, I get addDir event for C:\ immediately followed by unlinkDir for C:\. This happens before anything else is added.

Incidentally Chokidar seems to not like C: without the slash. Is this intended?

CxRes avatar Mar 22 '16 15:03 CxRes

Not sure what the unlinkDir is about. Can you show what is being emitted to the raw event when this happens? Have seen prior reports about issues trying to watch the root of C:\, but have not spent time trying to diagnose the issues. Even if some things got fixed, I wouldn't expect suitable performance trying to use chokidar to watch an entire system drive.

Is this intended?

No, it's probably fs.watch() that has an issue with it.

es128 avatar Mar 23 '16 14:03 es128

OK . This is strange... I am not getting any raw events before ready? I do not know what is wrong, tried different versions of Chokidar. HELP!!!!!!!!!!

I am watching with depth:1, so I guess performance is not the problem.

CxRes avatar Mar 23 '16 20:03 CxRes

This is actually expected. raw events are not emitted out of the file tree scan, just the watch methods. Do you see the unlinkDir event still without any raw and prior to ready?

es128 avatar Mar 23 '16 21:03 es128

With Code

watcher.on('all',function(event,path){
    console.log(event,':',path);    
});

My first two events are:

addDir : d:\
unlinkDir : d:\

These are all before the ready event. Then everything proceeds normally... (no raw events though as you describe)...

CxRes avatar Mar 24 '16 06:03 CxRes

@paulmillr it's still an issue. Happens when you start watching any root dir (C:\, D:\, etc.) on Windows. For example, if we watch C:\, after initial addDir C:\ it immediately runs unlinkDir: C:\ before getting to other dir items.

dirWatcher = chokidar
  .watch(path, {
    ignorePermissionErrors: true,
    ignored: /(^|[\/\\])\../,
    ignoreInitial: false,
    depth: 0,
    awaitWriteFinish: {
      stabilityThreshold: 2000,
    }
  })
  .on("all", (event, path) => {
    console.log(`event: ${event}, ${path}`)
  })

alexhx5 avatar Jan 20 '19 17:01 alexhx5