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 50afd34

Browse filesBrowse files
cjihrigtargos
authored andcommitted
fs: reduce unnecessary sync rimraf retries
rimraf should only retry if certain errors are encountered. Additionally, there is no point sleeping if an error occurs on the last try. PR-URL: #30785 Fixes: #30580 Refs: #30569 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent 4e05bf0 commit 50afd34
Copy full SHA for 50afd34

File tree

Expand file treeCollapse file tree

1 file changed

+10
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-3
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
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,19 @@ function _rmdirSync(path, options, originalErr) {
209209
rimrafSync(join(path, child), options);
210210
});
211211

212-
for (let i = 1; i <= options.maxRetries + 1; i++) {
212+
const tries = options.maxRetries + 1;
213+
214+
for (let i = 1; i <= tries; i++) {
213215
try {
214216
return rmdirSync(path, options);
215-
} catch {
216-
if (options.retryDelay > 0)
217+
} catch (err) {
218+
// Only sleep if this is not the last try, and the delay is greater
219+
// than zero, and an error was encountered that warrants a retry.
220+
if (retryErrorCodes.has(err.code) &&
221+
i < tries &&
222+
options.retryDelay > 0) {
217223
sleep(i * options.retryDelay);
224+
}
218225
}
219226
}
220227
}

0 commit comments

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