Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-08-05 21:02:53 +0300
committerGar <gar+gh@danger.computer>2021-08-05 21:02:53 +0300
commite82bcd4e8355d083f8f3eedb6251a5f3053d6dfd (patch)
tree3dc18e3679ff2414761dbd4fb0c2afce56f7b0e9 /node_modules
parent745326de0fae9f27f1deaf7729777aae48ac29fc (diff)
graceful-fs@4.2.7
* fix: start retrying immediately, stop after 10 attempts
Diffstat (limited to 'node_modules')
-rw-r--r--node_modules/graceful-fs/graceful-fs.js94
-rw-r--r--node_modules/graceful-fs/package.json2
2 files changed, 49 insertions, 47 deletions
diff --git a/node_modules/graceful-fs/graceful-fs.js b/node_modules/graceful-fs/graceful-fs.js
index e15042da9..1b0736c27 100644
--- a/node_modules/graceful-fs/graceful-fs.js
+++ b/node_modules/graceful-fs/graceful-fs.js
@@ -114,14 +114,13 @@ function patch (fs) {
return go$readFile(path, options, cb)
- function go$readFile (path, options, cb) {
+ function go$readFile (path, options, cb, attempts = 0) {
return fs$readFile(path, options, function (err) {
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$readFile, [path, options, cb]])
+ enqueue([go$readFile, [path, options, cb], attempts + 1, err])
else {
if (typeof cb === 'function')
cb.apply(this, arguments)
- retry()
}
})
}
@@ -135,14 +134,13 @@ function patch (fs) {
return go$writeFile(path, data, options, cb)
- function go$writeFile (path, data, options, cb) {
+ function go$writeFile (path, data, options, cb, attempts = 0) {
return fs$writeFile(path, data, options, function (err) {
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$writeFile, [path, data, options, cb]])
+ enqueue([go$writeFile, [path, data, options, cb], attempts + 1, err])
else {
if (typeof cb === 'function')
cb.apply(this, arguments)
- retry()
}
})
}
@@ -157,14 +155,13 @@ function patch (fs) {
return go$appendFile(path, data, options, cb)
- function go$appendFile (path, data, options, cb) {
+ function go$appendFile (path, data, options, cb, attempts = 0) {
return fs$appendFile(path, data, options, function (err) {
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$appendFile, [path, data, options, cb]])
+ enqueue([go$appendFile, [path, data, options, cb], attempts + 1, err])
else {
if (typeof cb === 'function')
cb.apply(this, arguments)
- retry()
}
})
}
@@ -178,49 +175,43 @@ function patch (fs) {
cb = flags
flags = 0
}
- return fs$copyFile(src, dest, flags, function (err) {
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([fs$copyFile, [src, dest, flags, cb]])
- else {
- if (typeof cb === 'function')
- cb.apply(this, arguments)
- retry()
- }
- })
+ return go$copyFile(src, dest, flags, cb)
+
+ function go$copyFile (src, dest, flags, cb, attempts = 0) {
+ return fs$copyFile(src, dest, flags, function (err) {
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
+ enqueue([go$copyFile, [src, dest, flags, cb], attempts + 1, err])
+ else {
+ if (typeof cb === 'function')
+ cb.apply(this, arguments)
+ }
+ })
+ }
}
var fs$readdir = fs.readdir
fs.readdir = readdir
function readdir (path, options, cb) {
- var args = [path]
- if (typeof options !== 'function') {
- args.push(options)
- } else {
- cb = options
- }
- args.push(go$readdir$cb)
-
- return go$readdir(args)
+ if (typeof options === 'function')
+ cb = options, options = null
- function go$readdir$cb (err, files) {
- if (files && files.sort)
- files.sort()
+ return go$readdir(path, options, cb)
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$readdir, [args]])
+ function go$readdir (path, options, cb, attempts = 0) {
+ return fs$readdir(path, options, function (err, files) {
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
+ enqueue([go$readdir, [path, options, cb], attempts + 1, err])
+ else {
+ if (files && files.sort)
+ files.sort()
- else {
- if (typeof cb === 'function')
- cb.apply(this, arguments)
- retry()
- }
+ if (typeof cb === 'function')
+ cb.call(this, err, files)
+ }
+ })
}
}
- function go$readdir (args) {
- return fs$readdir.apply(fs, args)
- }
-
if (process.version.substr(0, 4) === 'v0.8') {
var legStreams = legacy(fs)
ReadStream = legStreams.ReadStream
@@ -343,14 +334,13 @@ function patch (fs) {
return go$open(path, flags, mode, cb)
- function go$open (path, flags, mode, cb) {
+ function go$open (path, flags, mode, cb, attempts = 0) {
return fs$open(path, flags, mode, function (err, fd) {
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$open, [path, flags, mode, cb]])
+ enqueue([go$open, [path, flags, mode, cb], attempts + 1, err])
else {
if (typeof cb === 'function')
cb.apply(this, arguments)
- retry()
}
})
}
@@ -362,12 +352,24 @@ function patch (fs) {
function enqueue (elem) {
debug('ENQUEUE', elem[0].name, elem[1])
fs[gracefulQueue].push(elem)
+ retry()
}
function retry () {
+ if (fs[gracefulQueue].length === 0)
+ return
+
var elem = fs[gracefulQueue].shift()
if (elem) {
- debug('RETRY', elem[0].name, elem[1])
- elem[0].apply(null, elem[1])
+ const [fn, args, attempts, err] = elem
+ if (attempts < 10) {
+ debug('RETRY', fn.name, args, `ATTEMPT #${attempts}`)
+ fn.call(null, ...args, attempts)
+ } else {
+ const cb = args.pop()
+ if (typeof cb === 'function')
+ cb.call(null, err)
+ }
}
+ setImmediate(retry)
}
diff --git a/node_modules/graceful-fs/package.json b/node_modules/graceful-fs/package.json
index d73f971fc..accbf4c91 100644
--- a/node_modules/graceful-fs/package.json
+++ b/node_modules/graceful-fs/package.json
@@ -1,7 +1,7 @@
{
"name": "graceful-fs",
"description": "A drop-in replacement for fs, making various improvements.",
- "version": "4.2.6",
+ "version": "4.2.7",
"repository": {
"type": "git",
"url": "https://github.com/isaacs/node-graceful-fs"