-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
fs: fix busy loop in recursive rm for windows #36815
fs: fix busy loop in recursive rm for windows #36815
Conversation
cc @nodejs/fs |
Test is failing on Windows CI:
|
const middle = join(root, 'middle'); | ||
fs.mkdirSync(middle); | ||
fs.mkdirSync(join(middle, 'leaf')); // Make `middle` non-empty | ||
fs.chmodSync(middle, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stripping access permissions appears to have broken our Windows CI on the host the test ran on as subsequent jobs are unable to clean the workspace (as the user doesn't have permissions to remove this directory): nodejs/build#2526
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, that makes sense. tmpdir.refresh()
uses the rimraf code that's fixed here, and there's not usually a reason for tests to clean up their temp directories. I guess the problem could be solved by having this test do a tmpdir.refresh()
before exiting. And if we forget to ever remove that workaround, it's not a big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is tmpdir.refresh()
able to remove a directory where write permissions have been removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it locally and it does not seem to remove the directory. I think I'll have to change the permission before exiting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the code to change the permission for the directory to 0o777
before removing it and I don't see any temporary directories after this is run locally. PTAL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the earlier assertion fails (e.g. as in #36815 (comment)) then the reset of the permissions won't occur?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it does not reset the permissions.
try { | ||
assert.throws(() => { | ||
fs.rmdirSync(root, { recursive: true }); | ||
}, /EACCES/); | ||
} finally { | ||
fs.chmodSync(middle, 0o777); | ||
fs.rmdirSync(root, { recursive: true }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@richardlau This does reset the permissions regardless of the assertion.
9654955
to
28a50fd
Compare
If the same issue exists with
So the issue is that Windows doesn't throw a |
Sure, I'll do that.
Correct.
Oddly enough, Windows doesn't throw any of them. |
d71ec14
to
7f0eccd
Compare
5155d42
to
a474fcd
Compare
a474fcd
to
5572faa
Compare
Closing in favour of #38684 |
Fixes: #34580