Skip to content

Commit 0b88bbd

Browse files
cjihrigthangktran
authored andcommitted
fs: add ENFILE to rimraf retry logic
Co-authored-by: Thang Tran <[email protected]> Fixes: #30482 Refs: #30499 Refs: #30580 PR-URL: #30644 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 79e92fb commit 0b88bbd

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

doc/api/fs.md

+19-15
Original file line numberDiff line numberDiff line change
@@ -3225,7 +3225,8 @@ changes:
32253225
description: The `maxBusyTries` option is renamed to `maxRetries`, and its
32263226
default is 0. The `emfileWait` option has been removed, and
32273227
`EMFILE` errors use the same retry logic as other errors. The
3228-
`retryDelay` option is now supported.
3228+
`retryDelay` option is now supported. `ENFILE` errors are now
3229+
retried.
32293230
- version: v12.10.0
32303231
pr-url: https://github.com/nodejs/node/pull/29168
32313232
description: The `recursive`, `maxBusyTries`, and `emfileWait` options are
@@ -3248,11 +3249,11 @@ changes:
32483249
32493250
* `path` {string|Buffer|URL}
32503251
* `options` {Object}
3251-
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENOTEMPTY`, or `EPERM`
3252-
error is encountered, Node.js will retry the operation with a linear backoff
3253-
wait of `retryDelay` ms longer on each try. This option represents the number
3254-
of retries. This option is ignored if the `recursive` option is not `true`.
3255-
**Default:** `0`.
3252+
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
3253+
`EPERM` error is encountered, Node.js will retry the operation with a linear
3254+
backoff wait of `retryDelay` ms longer on each try. This option represents the
3255+
number of retries. This option is ignored if the `recursive` option is not
3256+
`true`. **Default:** `0`.
32563257
* `recursive` {boolean} If `true`, perform a recursive directory removal. In
32573258
recursive mode, errors are not reported if `path` does not exist, and
32583259
operations are retried on failure. **Default:** `false`.
@@ -3277,7 +3278,8 @@ changes:
32773278
description: The `maxBusyTries` option is renamed to `maxRetries`, and its
32783279
default is 0. The `emfileWait` option has been removed, and
32793280
`EMFILE` errors use the same retry logic as other errors. The
3280-
`retryDelay` option is now supported.
3281+
`retryDelay` option is now supported. `ENFILE` errors are now
3282+
retried.
32813283
- version: v12.10.0
32823284
pr-url: https://github.com/nodejs/node/pull/29168
32833285
description: The `recursive`, `maxBusyTries`, and `emfileWait` options are
@@ -3292,8 +3294,9 @@ changes:
32923294
32933295
* `path` {string|Buffer|URL}
32943296
* `options` {Object}
3295-
* `maxRetries` {integer} If an `EBUSY`, `ENOTEMPTY`, or `EPERM` error is
3296-
encountered, Node.js will retry the operation. This option represents the
3297+
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
3298+
`EPERM` error is encountered, Node.js will retry the operation with a linear
3299+
backoff wait of `retryDelay` ms longer on each try. This option represents the
32973300
number of retries. This option is ignored if the `recursive` option is not
32983301
`true`. **Default:** `0`.
32993302
* `recursive` {boolean} If `true`, perform a recursive directory removal. In
@@ -5014,7 +5017,8 @@ changes:
50145017
description: The `maxBusyTries` option is renamed to `maxRetries`, and its
50155018
default is 0. The `emfileWait` option has been removed, and
50165019
`EMFILE` errors use the same retry logic as other errors. The
5017-
`retryDelay` option is now supported.
5020+
`retryDelay` option is now supported. `ENFILE` errors are now
5021+
retried.
50185022
- version: v12.10.0
50195023
pr-url: https://github.com/nodejs/node/pull/29168
50205024
description: The `recursive`, `maxBusyTries`, and `emfileWait` options are
@@ -5025,11 +5029,11 @@ changes:
50255029
50265030
* `path` {string|Buffer|URL}
50275031
* `options` {Object}
5028-
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENOTEMPTY`, or `EPERM`
5029-
error is encountered, Node.js will retry the operation with a linear backoff
5030-
wait of `retryDelay` ms longer on each try. This option represents the number
5031-
of retries. This option is ignored if the `recursive` option is not `true`.
5032-
**Default:** `0`.
5032+
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
5033+
`EPERM` error is encountered, Node.js will retry the operation with a linear
5034+
backoff wait of `retryDelay` ms longer on each try. This option represents the
5035+
number of retries. This option is ignored if the `recursive` option is not
5036+
`true`. **Default:** `0`.
50335037
* `recursive` {boolean} If `true`, perform a recursive directory removal. In
50345038
recursive mode, errors are not reported if `path` does not exist, and
50355039
operations are retried on failure. **Default:** `false`.

lib/internal/fs/rimraf.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ 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']);
25+
const retryErrorCodes = new Set(
26+
['EBUSY', 'EMFILE', 'ENFILE', 'ENOTEMPTY', 'EPERM']);
2627
const isWindows = process.platform === 'win32';
2728
const epermHandler = isWindows ? fixWinEPERM : _rmdir;
2829
const epermHandlerSync = isWindows ? fixWinEPERMSync : _rmdirSync;

0 commit comments

Comments
 (0)