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

Workaround for the "Windows rough edge" regarding the deletion of directories #112

Closed
wants to merge 4 commits into from

Conversation

dkl-ppi
Copy link

@dkl-ppi dkl-ppi commented Apr 1, 2014

In the issue joyent/node#4337 it is recommended to add an error handler to the Windows watchers and to ignore the error. That's what this fix does. It adds an error handler, if the platform is "win32". To reduce the impact of the workaround, the error is only ignored, if the corresponding item doesn't exist.

// Workaround for the "Windows rough edge" regarding the deletion of directories
// (https://github.com/joyent/node/issues/4337)
if (platform === 'win32') {
watcher.on("error", function (err) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation please

// Workaround for the "Windows rough edge" regarding the deletion of directories
// (https://github.com/joyent/node/issues/4337)
if (platform === 'win32') {
watcher.on("error", function (err) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can check for error code here and execute fs.exists only for some errors?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error object you get is { [Error: watch EPERM] code: 'EPERM', errno: 'EPERM', syscall: 'watch' }. It's not very meaningful, but we could check the error code to reduce the impact of the workaround further. On the other hand it can't hurt to ignore errors for non existing items. I'll leave the decision to you.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's limit this to EPERM for now. We can expand it later.

@dkl-ppi
Copy link
Author

dkl-ppi commented Apr 11, 2014

@paulmillr are you satisfied with the current solution? If so then it would be nice if you would merge and release the change. I am currently replacing fs-watch-tree with chokidar in buster.js and i need this fix therefor.

@es128
Copy link
Contributor

es128 commented Apr 11, 2014

@dwittner it would probably be a good idea to squash the additional commits that were added subsequent to code review to get the PR ready for merge

paulmillr added a commit that referenced this pull request Apr 15, 2014
@paulmillr paulmillr closed this Apr 15, 2014
@paulmillr
Copy link
Owner

I have improved your algorithm — now behaves as before for real

@dkl-ppi
Copy link
Author

dkl-ppi commented May 14, 2014

@paulmillr, when will the fix approximately be published?

@dkl-ppi
Copy link
Author

dkl-ppi commented Sep 16, 2014

@paulmillr, unfortunately the improvement doesn't seem to work, i still get the error "Error: watch EPERM". Do i do something wrong?

@paulmillr
Copy link
Owner

are you using github version? do you actually have right permissions?

@dkl-ppi
Copy link
Author

dkl-ppi commented Sep 17, 2014

I use npm version 0.8.4, which seems to contain the fix for the windows rough edge.
What do you mean with "right permissions"? For the directory i try to delete?
The test case is, that i first create the directory and then delete it.

@paulmillr
Copy link
Owner

well that's weird then. no idea why this happens, sorry

@Cominch
Copy link

Cominch commented Oct 2, 2014

Now your code raises an exception:

index.js:289
fs.exists(item, function(exists) {
ReferenceError: item is not defined

... because it's not passed as Parameter

@dkl-ppi
Copy link
Author

dkl-ppi commented Oct 2, 2014

@paulmillr, could you please fix your modification to fix the ReferenceError?

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

Successfully merging this pull request may close these issues.

4 participants