Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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.
  • Loading branch information
cjihrig committed Dec 8, 2019
commit 2dd26b08d1c0dc99626f92571259475b87a2029a
13 changes: 10 additions & 3 deletions lib/internal/fs/rimraf.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,19 @@ function _rmdirSync(path, options, originalErr) {
rimrafSync(join(path, child), options);
});

for (let i = 1; i <= options.maxRetries + 1; i++) {
const tries = options.maxRetries + 1;

for (let i = 1; i <= tries; i++) {
try {
return rmdirSync(path, options);
} catch {
if (options.retryDelay > 0)
} catch (err) {
// Only sleep if this is not the last try, and the delay is greater
// than zero, and an error was encountered that warrants a retry.
if (retryErrorCodes.has(err.code) &&
i < tries &&
options.retryDelay > 0) {
sleep(i * options.retryDelay);
}
}
}
}
Expand Down