-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Trying to rename() a directory over another fails slowly on Windows #98
Comments
When trying to rename a directory over another directory, graceful-fs-4.1.10 (maybe other versions?) takes 1 minute to fail the call with an error. This causes the test to timeout. The workaround is to increase the timeout of that one test to 1m30s. See isaacs/node-graceful-fs#98
This is a regression. Renaming a directory over another used to fail fairly instantly in graceful-fs-4.1.9. |
This is because of 59145ce. @sam-github, any thoughts? |
I know it would be racy, but retrying is already introducing potential race conditions. I don’t think that the return error code of |
So, it used to retry, it just retries longer now. Though enough longer, I guess you are noticing it? The existing code checked for `er.code === "EACCES" || er.code === "EPERM", it only retries if it is one of those. I agree, it looks like the underlying node error code doesn't contain enough information to know if its a temporary failure, to be retried, or permanent. The slow retry loop that gives time for virus checkers to complete could be moved out of graceful-fs, and into npm. I'm not clear if it is a loop that should ever have been in graceful-fs... I understand graceful-fs to retry on fd exhuastion, but should it also retry on fs errors? @isaacs, what is this history? Is this retry loop something that should be hoisted into npm proper, out of graceful-fs? |
I personally like that this loop is in graceful-fs because this is a Windows weirdness that people should be able to magically supporting just by using it. But I think that with the right type of operations, even the short 1s loop could cause programs which run fine on Unix to be unusably slow on Windows if they rely on |
Here’s the output from graceful-fs-4.1.9 for reference, especially now that I know why this is 1.275s (compared to
|
I'd be fine with statting the target to see if it exists. Anything but a failure with |
When `rename` is used on Windows, and encounters an EPERM or EACCES error, graceful-fs will retry for up to 30 seconds with gradual backoff to get around file system locking due to A/V etc. This was fixed in 59145ce However, this is a problem if the target exists, which can cause an EPERM or EACCES that is not due to folder locking. This commit causes it to fail fast when an EPERM or EACCES is raised by rename if the target exists. Fix #98
@binki Can you If it does, then I'll land and publish this as a patch release. |
@isaacs That seems to fix it. The operation looks like it runs instantly so that the project’s tests run fine without having to extend the timeout. Thanks! |
It should fail instantly, like with
fs.rename
:The text was updated successfully, but these errors were encountered: