Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4e05bf0

Browse filesBrowse files
cjihrigtargos
authored andcommitted
fs: add synchronous retries to rimraf
This commit gives the synchronous version of rimraf the same linear retry logic as the asynchronous version. Prior to this commit, sync rimraf kept retrying the operation as soon as possible until maxRetries was reached. PR-URL: #30785 Fixes: #30580 Refs: #30569 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent e1eb6a6 commit 4e05bf0
Copy full SHA for 4e05bf0

File tree

Expand file treeCollapse file tree

1 file changed

+6
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-2
lines changed
Open diff view settings
Collapse file

‎lib/internal/fs/rimraf.js‎

Copy file name to clipboardExpand all lines: lib/internal/fs/rimraf.js
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const {
2121
} = require('fs');
2222
const { join } = require('path');
2323
const { setTimeout } = require('timers');
24+
const { sleep } = require('internal/util');
2425
const notEmptyErrorCodes = new Set(['ENOTEMPTY', 'EEXIST', 'EPERM']);
2526
const retryErrorCodes = new Set(
2627
['EBUSY', 'EMFILE', 'ENFILE', 'ENOTEMPTY', 'EPERM']);
@@ -208,10 +209,13 @@ function _rmdirSync(path, options, originalErr) {
208209
rimrafSync(join(path, child), options);
209210
});
210211

211-
for (let i = 0; i < options.maxRetries + 1; i++) {
212+
for (let i = 1; i <= options.maxRetries + 1; i++) {
212213
try {
213214
return rmdirSync(path, options);
214-
} catch {} // Ignore errors.
215+
} catch {
216+
if (options.retryDelay > 0)
217+
sleep(i * options.retryDelay);
218+
}
215219
}
216220
}
217221
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.