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 51bc379

Browse filesBrowse 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
Copy full SHA for 51bc379

File tree

Expand file treeCollapse file tree

4 files changed

+18
-39
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+18
-39
lines changed
Open diff view settings
Collapse file

‎doc/api/fs.md‎

Copy file name to clipboardExpand all lines: doc/api/fs.md
+16-19Lines changed: 16 additions & 19 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -3223,7 +3223,8 @@ changes:
32233223
- version: REPLACEME
32243224
pr-url: https://github.com/nodejs/node/pull/30644
32253225
description: The `maxBusyTries` option is renamed to `maxRetries`, and its
3226-
default is 0.
3226+
default is 0. The `emfileWait` option has been removed, and
3227+
`EMFILE` errors use the same retry logic as other errors.
32273228
- version: v12.10.0
32283229
pr-url: https://github.com/nodejs/node/pull/29168
32293230
description: The `recursive`, `maxBusyTries`, and `emfileWait` options are
@@ -3246,14 +3247,11 @@ changes:
32463247
32473248
* `path` {string|Buffer|URL}
32483249
* `options` {Object}
3249-
* `emfileWait` {integer} If an `EMFILE` error is encountered, Node.js will
3250-
retry the operation with a linear backoff of 1ms longer on each try until the
3251-
timeout duration passes this limit. This option is ignored if the `recursive`
3252-
option is not `true`. **Default:** `1000`.
3253-
* `maxRetries` {integer} If an `EBUSY`, `ENOTEMPTY`, or `EPERM` error is
3254-
encountered, Node.js will retry the operation with a linear backoff wait of
3255-
100ms longer on each try. This option represents the number of retries. This
3256-
option is ignored if the `recursive` option is not `true`. **Default:** `0`.
3250+
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENOTEMPTY`, or `EPERM`
3251+
error is encountered, Node.js will retry the operation with a linear backoff
3252+
wait of 100ms longer on each try. This option represents the number of
3253+
retries. This option is ignored if the `recursive` option is not `true`.
3254+
**Default:** `0`.
32573255
* `recursive` {boolean} If `true`, perform a recursive directory removal. In
32583256
recursive mode, errors are not reported if `path` does not exist, and
32593257
operations are retried on failure. **Default:** `false`.
@@ -3273,7 +3271,8 @@ changes:
32733271
- version: REPLACEME
32743272
pr-url: https://github.com/nodejs/node/pull/30644
32753273
description: The `maxBusyTries` option is renamed to `maxRetries`, and its
3276-
default is 0.
3274+
default is 0. The `emfileWait` option has been removed, and
3275+
`EMFILE` errors use the same retry logic as other errors.
32773276
- version: v12.10.0
32783277
pr-url: https://github.com/nodejs/node/pull/29168
32793278
description: The `recursive`, `maxBusyTries`, and `emfileWait` options are
@@ -5005,7 +5004,8 @@ changes:
50055004
- version: REPLACEME
50065005
pr-url: https://github.com/nodejs/node/pull/30644
50075006
description: The `maxBusyTries` option is renamed to `maxRetries`, and its
5008-
default is 0.
5007+
default is 0. The `emfileWait` option has been removed, and
5008+
`EMFILE` errors use the same retry logic as other errors.
50095009
- version: v12.10.0
50105010
pr-url: https://github.com/nodejs/node/pull/29168
50115011
description: The `recursive`, `maxBusyTries`, and `emfileWait` options are
@@ -5016,14 +5016,11 @@ changes:
50165016
50175017
* `path` {string|Buffer|URL}
50185018
* `options` {Object}
5019-
* `emfileWait` {integer} If an `EMFILE` error is encountered, Node.js will
5020-
retry the operation with a linear backoff of 1ms longer on each try until the
5021-
timeout duration passes this limit. This option is ignored if the `recursive`
5022-
option is not `true`. **Default:** `1000`.
5023-
* `maxRetries` {integer} If an `EBUSY`, `ENOTEMPTY`, or `EPERM` error is
5024-
encountered, Node.js will retry the operation with a linear backoff wait of
5025-
100ms longer on each try. This option represents the number of retries. This
5026-
option is ignored if the `recursive` option is not `true`. **Default:** `0`.
5019+
* `maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENOTEMPTY`, or `EPERM`
5020+
error is encountered, Node.js will retry the operation with a linear backoff
5021+
wait of 100ms longer on each try. This option represents the number of
5022+
retries. This option is ignored if the `recursive` option is not `true`.
5023+
**Default:** `0`.
50275024
* `recursive` {boolean} If `true`, perform a recursive directory removal. In
50285025
recursive mode, errors are not reported if `path` does not exist, and
50295026
operations are retried on failure. **Default:** `false`.
Collapse file

‎lib/internal/fs/rimraf.js‎

Copy file name to clipboardExpand all lines: lib/internal/fs/rimraf.js
+2-6Lines 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;
Collapse file

‎lib/internal/fs/utils.js‎

Copy file name to clipboardExpand all lines: lib/internal/fs/utils.js
-3Lines 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;
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-fs-rmdir-recursive.js
-11Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,10 @@ function removeAsync(dir) {
155155
// Test input validation.
156156
{
157157
const defaults = {
158-
emfileWait: 1000,
159158
maxRetries: 0,
160159
recursive: false
161160
};
162161
const modified = {
163-
emfileWait: 953,
164162
maxRetries: 5,
165163
recursive: true
166164
};
@@ -171,7 +169,6 @@ function removeAsync(dir) {
171169
assert.deepStrictEqual(validateRmdirOptions({
172170
maxRetries: 99
173171
}), {
174-
emfileWait: 1000,
175172
maxRetries: 99,
176173
recursive: false
177174
});
@@ -196,14 +193,6 @@ function removeAsync(dir) {
196193
});
197194
});
198195

199-
common.expectsError(() => {
200-
validateRmdirOptions({ emfileWait: -1 });
201-
}, {
202-
code: 'ERR_OUT_OF_RANGE',
203-
type: RangeError,
204-
message: /^The value of "emfileWait" is out of range\./
205-
});
206-
207196
common.expectsError(() => {
208197
validateRmdirOptions({ maxRetries: -1 });
209198
}, {

0 commit comments

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