shama / gaze

:crystal_ball: A globbing fs.watch wrapper built from the best parts of other fine watch libs.
MIT License
1.16k stars 167 forks source link

Gaze crashes when a non-empty folder is permanently removed #248

Closed kireerik closed 6 years ago

kireerik commented 6 years ago

No event is fired when a non-empty folder is deleted. Once it is deleted from the recycle bin I get the following error:

events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: EPERM: operation not permitted, watch
    at FSEvent.FSWatcher._handle.onchange (fs.js:1372:28)
Emitted 'error' event at:
    at Gaze.emit (node_modules\gaze\lib\gaze.js:102:32)
    at Gaze._handleError (node_modules\gaze\lib\gaze.js:468:15)
    at FSWatcher.<anonymous> (node_modules\gaze\lib\gaze.js:328:12)    at FSWatcher.emit (events.js:182:13)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1378:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

System: Windows 10 Pro 1083 Gaze version: 1.1.3

Note: @paulmillr's and @es128's chokidar, @balupton's @bevry's watchr and maybe @amasad's sane (I don't remember if I tried it or not.) has the exact same issue. I did't tried watch and node-pathwatcher, but they probably has this issue as well.

balupton commented 6 years ago

What about Facebook’s watchman?

shama commented 6 years ago

EPERM: operation not permitted, watch

There really isnt anything we can do to get around file system permissions. If you don't want to see the error or would like to handle the error differently, add an event listener for the error and handle it.

kireerik commented 6 years ago

@balupton I didn't tried it.

@shama The issue also exists if I force delete the folder. Yes it is definitely a potential workaround.

kireerik commented 6 years ago

I think we should probably keep this issue opened since it can be related to the other issue I have reported.

I can see somewhat similar, but really old issues however which are probably resolved and are closeable by now.

shama commented 6 years ago

I dont see how it is related and I cannot fix EPERM for you. If the library doesnt have permissions on your machine it simply doesnt have permissions. Either give it permissions, handle the error or ignore the error.

kireerik commented 6 years ago

I don't want you to fix this for me. Also it looks like to me that Gaze is trying to watch something which was just deleted. Permanently deleting an empty directory works without any issue, but when you have at least one file in the folder it doesn't works (at least under Windows).

kireerik commented 5 years ago

Related issue: https://github.com/shama/gaze/issues/44