fs: remove rimraf's emfileWait option · nodejs/node@51bc379 · GitHub
Skip to content

Commit 51bc379

Browse files
cjihrigaddaleax
authored andcommitted
fs: remove rimraf's emfileWait option
This commit removes the emfileWait option. EMFILE errors are now handled the same as any other retriable error. Refs: #30580 PR-URL: #30644 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 612a3a2 commit 51bc379

4 files changed

Lines changed: 18 additions & 39 deletions

File tree

doc/api/fs.md

Lines changed: 16 additions & 19 deletions

lib/internal/fs/rimraf.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,22 @@ const {
2222
const { join } = require('path');
2323
const { setTimeout } = require('timers');
2424
const notEmptyErrorCodes = new Set(['ENOTEMPTY', 'EEXIST', 'EPERM']);
25+
const retryErrorCodes = new Set(['EBUSY', 'EMFILE', 'ENOTEMPTY', 'EPERM']);
2526
const isWindows = process.platform === 'win32';
2627
const epermHandler = isWindows ? fixWinEPERM : _rmdir;
2728
const epermHandlerSync = isWindows ? fixWinEPERMSync : _rmdirSync;
2829

2930

3031
function rimraf(path, options, callback) {
31-
let timeout = 0; // For EMFILE handling.
3232
let retries = 0;
3333

3434
_rimraf(path, options, function CB(err) {
3535
if (err) {
36-
if ((err.code === 'EBUSY' || err.code === 'ENOTEMPTY' ||
37-
err.code === 'EPERM') && retries < options.maxRetries) {
36+
if (retryErrorCodes.has(err.code) && retries < options.maxRetries) {
3837
retries++;
3938
return setTimeout(_rimraf, retries * 100, path, options, CB);
4039
}
4140

42-
if (err.code === 'EMFILE' && timeout < options.emfileWait)
43-
return setTimeout(_rimraf, timeout++, path, options, CB);
44-
4541
// The file is already gone.
4642
if (err.code === 'ENOENT')
4743
err = null;

lib/internal/fs/utils.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const {
2424
const { once } = require('internal/util');
2525
const { toPathIfFileURL } = require('internal/url');
2626
const {
27-
validateInt32,
2827
validateUint32
2928
} = require('internal/validators');
3029
const pathModule = require('path');
@@ -562,7 +561,6 @@ function warnOnNonPortableTemplate(template) {
562561
}
563562

564563
const defaultRmdirOptions = {
565-
emfileWait: 1000,
566564
maxRetries: 0,
567565
recursive: false,
568566
};
@@ -578,7 +576,6 @@ const validateRmdirOptions = hideStackFrames((options) => {
578576
if (typeof options.recursive !== 'boolean')
579577
throw new ERR_INVALID_ARG_TYPE('recursive', 'boolean', options.recursive);
580578

581-
validateInt32(options.emfileWait, 'emfileWait', 0);
582579
validateUint32(options.maxRetries, 'maxRetries');
583580

584581
return options;

test/parallel/test-fs-rmdir-recursive.js

Lines changed: 0 additions & 11 deletions

0 commit comments

Comments
 (0)