-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: start retrying immediately, stop after 10 attempts
PR-URL: #217 Credit: @nlf Close: #217 Reviewed-by: @isaacs, @wraithgar
- Loading branch information
Showing
3 changed files
with
50 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict' | ||
|
||
var importFresh = require('import-fresh') | ||
var path = require('path') | ||
var realFs = require('fs') | ||
var test = require('tap').test | ||
|
||
var EMFILE = Object.assign(new Error('FAKE EMFILE'), { code: 'EMFILE' }) | ||
|
||
test('retries 10 times before erroring', function (t) { | ||
var attempts = 0 | ||
realFs.readFile = function (path, options, cb) { | ||
++attempts | ||
process.nextTick(cb, EMFILE) | ||
} | ||
var fs = importFresh(path.dirname(__dirname)) | ||
|
||
fs.readFile('literally anything', function (err) { | ||
t.equal(err.code, 'EMFILE', 'eventually got the EMFILE') | ||
t.equal(attempts, 10, 'tried 10 times') | ||
t.done() | ||
}) | ||
}) |
this breaks node <= 4, which graceful-fs 4 works on.
also this line doesn't seem to be in the PR - was it added as part of the merge?