Skip to content

Commit 7a32198

Browse files
cjihrigBethGriggs
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 <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent ccc228b commit 7a32198

File tree

4 files changed

+18
-39
lines changed

4 files changed

+18
-39
lines changed

‎doc/api/fs.md‎

Lines changed: 16 additions & 19 deletions
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`.

‎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
constnotEmptyErrorCodes=newSet(['ENOTEMPTY','EEXIST','EPERM']);
25+
constretryErrorCodes=newSet(['EBUSY','EMFILE','ENOTEMPTY','EPERM']);
2526
constisWindows=process.platform==='win32';
2627
constepermHandler=isWindows ? fixWinEPERM : _rmdir;
2728
constepermHandlerSync=isWindows ? fixWinEPERMSync : _rmdirSync;
2829

2930

3031
functionrimraf(path,options,callback){
31-
lettimeout=0;// For EMFILE handling.
3232
letretries=0;
3333

3434
_rimraf(path,options,functionCB(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
returnsetTimeout(_rimraf,retries*100,path,options,CB);
4039
}
4140

42-
if(err.code==='EMFILE'&&timeout<options.emfileWait)
43-
returnsetTimeout(_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
constpathModule=require('path');
@@ -563,7 +562,6 @@ function warnOnNonPortableTemplate(template){
563562
}
564563

565564
constdefaultRmdirOptions={
566-
emfileWait: 1000,
567565
maxRetries: 0,
568566
recursive: false,
569567
};
@@ -579,7 +577,6 @@ const validateRmdirOptions = hideStackFrames((options) =>{
579577
if(typeofoptions.recursive!=='boolean')
580578
thrownewERR_INVALID_ARG_TYPE('recursive','boolean',options.recursive);
581579

582-
validateInt32(options.emfileWait,'emfileWait',0);
583580
validateUint32(options.maxRetries,'maxRetries');
584581

585582
returnoptions;

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

Lines 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
constdefaults={
158-
emfileWait: 1000,
159158
maxRetries: 0,
160159
recursive: false
161160
};
162161
constmodified={
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: /^Thevalueof"emfileWait"isoutofrange\./
205-
});
206-
207196
common.expectsError(()=>{
208197
validateRmdirOptions({maxRetries: -1});
209198
},{

0 commit comments

Comments
(0)