Skip to content

Commit

Permalink
fs: add ENFILE to rimraf retry logic
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
2 people authored and addaleax committed Nov 30, 2019
1 parent f725953 commit 3475f9b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
34 changes: 19 additions & 15 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3225,7 +3225,8 @@ changes:
description: The `maxBusyTries` option is renamed to `maxRetries`, and its
default is 0. The `emfileWait` option has been removed, and
`EMFILE` errors use the same retry logic as other errors. The
`retryDelay` option is now supported.
`retryDelay` option is now supported. `ENFILE` errors are now
retried.
- version: v12.10.0
pr-url: https://github.com/nodejs/node/pull/29168
description: The `recursive`, `maxBusyTries`, and `emfileWait` options are
Expand All @@ -3248,11 +3249,11 @@ changes:
* `path` {string|Buffer|URL}
* `options` {Object}
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENOTEMPTY`, or `EPERM`
error is encountered, Node.js will retry the operation with a linear backoff
wait of `retryDelay` ms longer on each try. This option represents the number
of retries. This option is ignored if the `recursive` option is not `true`.
**Default:** `0`.
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
`EPERM` error is encountered, Node.js will retry the operation with a linear
backoff wait of `retryDelay` ms longer on each try. This option represents the
number of retries. This option is ignored if the `recursive` option is not
`true`. **Default:** `0`.
* `recursive` {boolean} If `true`, perform a recursive directory removal. In
recursive mode, errors are not reported if `path` does not exist, and
operations are retried on failure. **Default:** `false`.
Expand All @@ -3277,7 +3278,8 @@ changes:
description: The `maxBusyTries` option is renamed to `maxRetries`, and its
default is 0. The `emfileWait` option has been removed, and
`EMFILE` errors use the same retry logic as other errors. The
`retryDelay` option is now supported.
`retryDelay` option is now supported. `ENFILE` errors are now
retried.
- version: v12.10.0
pr-url: https://github.com/nodejs/node/pull/29168
description: The `recursive`, `maxBusyTries`, and `emfileWait` options are
Expand All @@ -3292,8 +3294,9 @@ changes:
* `path` {string|Buffer|URL}
* `options` {Object}
* `maxRetries` {integer} If an `EBUSY`, `ENOTEMPTY`, or `EPERM` error is
encountered, Node.js will retry the operation. This option represents the
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
`EPERM` error is encountered, Node.js will retry the operation with a linear
backoff wait of `retryDelay` ms longer on each try. This option represents the
number of retries. This option is ignored if the `recursive` option is not
`true`. **Default:** `0`.
* `recursive` {boolean} If `true`, perform a recursive directory removal. In
Expand Down Expand Up @@ -5014,7 +5017,8 @@ changes:
description: The `maxBusyTries` option is renamed to `maxRetries`, and its
default is 0. The `emfileWait` option has been removed, and
`EMFILE` errors use the same retry logic as other errors. The
`retryDelay` option is now supported.
`retryDelay` option is now supported. `ENFILE` errors are now
retried.
- version: v12.10.0
pr-url: https://github.com/nodejs/node/pull/29168
description: The `recursive`, `maxBusyTries`, and `emfileWait` options are
Expand All @@ -5025,11 +5029,11 @@ changes:
* `path` {string|Buffer|URL}
* `options` {Object}
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENOTEMPTY`, or `EPERM`
error is encountered, Node.js will retry the operation with a linear backoff
wait of `retryDelay` ms longer on each try. This option represents the number
of retries. This option is ignored if the `recursive` option is not `true`.
**Default:** `0`.
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
`EPERM` error is encountered, Node.js will retry the operation with a linear
backoff wait of `retryDelay` ms longer on each try. This option represents the
number of retries. This option is ignored if the `recursive` option is not
`true`. **Default:** `0`.
* `recursive` {boolean} If `true`, perform a recursive directory removal. In
recursive mode, errors are not reported if `path` does not exist, and
operations are retried on failure. **Default:** `false`.
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/fs/rimraf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const {
const { join } = require('path');
const { setTimeout } = require('timers');
const notEmptyErrorCodes = new Set(['ENOTEMPTY', 'EEXIST', 'EPERM']);
const retryErrorCodes = new Set(['EBUSY', 'EMFILE', 'ENOTEMPTY', 'EPERM']);
const retryErrorCodes = new Set(
['EBUSY', 'EMFILE', 'ENFILE', 'ENOTEMPTY', 'EPERM']);
const isWindows = process.platform === 'win32';
const epermHandler = isWindows ? fixWinEPERM : _rmdir;
const epermHandlerSync = isWindows ? fixWinEPERMSync : _rmdirSync;
Expand Down

0 comments on commit 3475f9b

Please sign in to comment.