Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 7, Chokidar exits with error when remove a directory #88

Closed
jeromedecoster opened this issue Dec 24, 2013 · 16 comments
Closed

Windows 7, Chokidar exits with error when remove a directory #88

jeromedecoster opened this issue Dec 24, 2013 · 16 comments

Comments

@jeromedecoster
Copy link

Hi,

On Windows 7, lastest nodejs, latest chokidar

I have this simple test file:

var chokidar = require('chokidar');

var watcher = chokidar.watch('./client', {persistent: true});

watcher
  .on('add', function(path) {console.log('File', path, 'has been added');})
  .on('addDir', function(path) {console.log('Directory', path, 'has been added');})
  .on('change', function(path) {console.log('File', path, 'has been changed');})
  .on('unlink', function(path) {console.log('File', path, 'has been removed');})
  .on('unlinkDir', function(path) {console.log('Directory', path, 'has been removed');})
  .on('error', function(error) {console.error('Error happened', error);})

When I run the script I have:

Directory ./client has been added

If I add a directory mkdir a, I have:

Directory ./client has been added
Directory client\a has been added

But if I remove the dir rm -rf ./a I have this error and the script exits

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: watch EPERM
    at errnoException (fs.js:1019:11)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1037:26)
@paulmillr
Copy link
Owner

This is node.js core error nodejs/node-v0.x-archive#4337

But we need to handle this one, yes

dkl-ppi added a commit to dkl-ppi/chokidar that referenced this issue Apr 1, 2014
@Cominch
Copy link

Cominch commented Oct 1, 2014

Would you like to pull this fix into the main repository?

@dkl-ppi
Copy link

dkl-ppi commented Oct 1, 2014

The fix is already merged into the main repository (#112), but unfortunately it got a few improvements, so that it isn't working any longer.

@Cominch
Copy link

Cominch commented Oct 2, 2014

Bug see #112

@es128 es128 closed this as completed in 2913fae Oct 10, 2014
@es128
Copy link
Contributor

es128 commented Oct 10, 2014

@dwittner please verify whether 2913fae does the trick

@dkl-ppi
Copy link

dkl-ppi commented Oct 11, 2014

@es128, it seems to work now, at least i don't get an error anymore. Thus it is an improvement in any case. Can you tell me, when the fix will be released?

@Cominch
Copy link

Cominch commented Oct 11, 2014

Additional comment: I had to put a try... catch around _handleFile and _handleDir calls in the _handle Subroutine, but unfortunately I was not able to track down the error in Detail.
I will try to investigate further, and try to identify the exception.

@es128
Copy link
Contributor

es128 commented Oct 11, 2014

I don't think I have npm rights on chokidar yet, but I'd probably want to take another week or so to fix any other issues I can track down and try to make sure it's stable before I recommend an 0.10 release.

@Cominch
Copy link

Cominch commented Oct 11, 2014

even with my try... catch Approach, I don't manage to handle all "unhandled 'error' events"
two are still remaining: Unknown System errno 58 and Unknown Sytem errno 56
But this applies mainly to Networked shared Folders on Windows, which is also mentioned in multiple other issues

@dkl-ppi
Copy link

dkl-ppi commented Oct 11, 2014

@Cominch, what are your test cases? With the solution of @es128, i can add and delete folders on Windows without any errors.

@Cominch
Copy link

Cominch commented Oct 11, 2014

it's now limited to Windows Network Shares, and happens sporadically during the _handle.onchange Event.
As I programmatically open every detected added file with write and Change flags, it's limited to Change Events. Deleting seems to be painless now.

@Cominch
Copy link

Cominch commented Oct 11, 2014

hm... i think now it says EPERM again while lstat'ting:

Cannot call method "emit" of undefined, in chokidar\index.js:294 tracing back to index.js:286, where it emits something ALTHOUGH I'm on Windows, and it clearly says ...raised an error: EPERM, lstat

@es128
Copy link
Contributor

es128 commented Oct 11, 2014

@Cominch please provide code and describe steps to reproduce

@dkl-ppi
Copy link

dkl-ppi commented Oct 21, 2014

@es128, 0.10.1 works fine for me now. Thx a lot!

@kafoso
Copy link

kafoso commented Jun 10, 2016

Necro, but still relevant.

This error may be caused by deleting a file from within an application being run as a different user on the system. E.g. running a text editor as Administrator (Windows) and deleting the file from within this editor will trigger the error.

@Myasir92
Copy link

chokidar file remove and unwatch is not working if i add a function to watch but after this i try to remove it or unwatch it but it didnt remove it not unwatch it can you please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants