fs: fix busy loop in recursive rm for windows#36815
fs: fix busy loop in recursive rm for windows#36815RaisinTen wants to merge 3 commits intonodejs:masterfrom
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.
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.
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.
Is tmpdir.refresh() able to remove a directory where write permissions have been removed?
There was a problem hiding this comment.
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.
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.
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.
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.
@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