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

Try to fix EPERM #185

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function patch (fs) {
&& Date.now() - start < 60000) {
setTimeout(function() {
fs.stat(to, function (stater, st) {
if (stater && stater.code === "ENOENT")
if ((stater && stater.code === "ENOENT") || (st && st.isFile()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you explain this fix, maybe add a comment? Is the situation that to already exists but is maybe open by another process so windows gives EACCES or EPERM when trying to overwrite the destination?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, as explained in this #104 (comment) , after the stat check was added, he started seeing these errors. to already exists because it is a config file that is being atomically renamed to (overwritten). The stat check was added because the retry mechanism was causing a long retry delay in the case that to is a directory because it would give the same error and thereby retry until timeout. Therefore with st.isFile() it should still give up on directories.

fs$rename(from, to, CB);
else
cb(er)
Expand Down