-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
rmdirSync returns before too early causing "operation not permitted" on next operation #18805
Comments
What's the point of removing the directory just to create it again? The directory already has to be empty to remove it. Why not just call |
That is just an example. |
Can you post a minimal, ready-to-run test case rather than an excerpt? The devil frequently is in the details. |
I can repro it here: https://github.com/unional/issues/tree/node-fs It can very consistently reproduce the behavior. It just follows a pass -> fail -> pass -> fail pattern. It seems like there is some sync issue between node's So I don't know if it is node's related or more like However, it is strange that the same thing does not happen in OSX. I run the same code in OSX and it is working fine. So it might still worth investigating. 🌷 |
There's that devil. :-) You're running into a Windows quirk where file watching takes out a lock on the directory being watched. It's not specific to Node.js. Some of the caveats are listed in the I'll close this out. Thanks anyway for the report. |
Thanks. Learning something new everyday. 👍 Seems like you are referring to this: Note: When a file being watched by fs.watchFile() disappears and reappears, then the previousStat reported in the second callback event (the file's reappearance) will be the same as the previousStat of the first callback event (its disappearance).
This happens when:
the file is deleted, followed by a restore
the file is renamed twice - the second time back to its original name So for the However, what's strange is that the |
Hm, maybe the note was removed; it's only hinted at obliquely now. If you google for "ReadDirectoryChanges ERROR_ACCESS_DENIED", you'll get a couple of hits that explain the issue. ReadDirectoryChanges is the operating system API that Node.js uses on Windows. |
node: 9.4.0
OS: Windows Server 2016
This code causes "operation not permitted" on
mkdir
on every 2nd attemptif (fs.existsSync(dir)) fs.rmdirSync(dir) fs.mkdirSync(dir)
The callback version works fine:
The text was updated successfully, but these errors were encountered: