diff --git a/node_modules/graceful-fs/graceful-fs.js b/node_modules/graceful-fs/graceful-fs.js index 5d136c27f96..be9951eacd5 100644 --- a/node_modules/graceful-fs/graceful-fs.js +++ b/node_modules/graceful-fs/graceful-fs.js @@ -65,10 +65,8 @@ function open (path, flags, mode, cb) { fs.openSync = function (path, flags, mode) { var ret - try { - ret = originalOpenSync.call(fs, path, flags, mode) - fs._curOpen ++ - } finally {} + ret = originalOpenSync.call(fs, path, flags, mode) + fs._curOpen ++ return ret } @@ -261,7 +259,6 @@ if (!fs.lchown) { - // on Windows, A/V software can lock the directory, causing this // to fail with an EACCES or EPERM if the directory contains newly // created files. Try again on failure, for up to 1 second. @@ -279,3 +276,37 @@ if (process.platform === "win32") { }) } } + + +// if read() returns EAGAIN, then just try it again. +var read = fs.read +fs.read = function (fd, buffer, offset, length, position, callback_) { + var callback + if (callback_ && typeof callback_ === 'function') { + var eagCounter = 0 + callback = function (er, _, __) { + if (er && er.code === 'EAGAIN' && eagCounter < 10) { + eagCounter ++ + return read.call(fs, fd, buffer, offset, length, position, callback) + } + callback_.apply(this, arguments) + } + } + return read.call(fs, fd, buffer, offset, length, position, callback) +} + +var readSync = fs.readSync +fs.readSync = function (fd, buffer, offset, length, position) { + var eagCounter = 0 + while (true) { + try { + return readSync.call(fs, fd, buffer, offset, length, position) + } catch (er) { + if (er.code === 'EAGAIN' && eagCounter < 10) { + eagCounter ++ + continue + } + throw er + } + } +} diff --git a/node_modules/graceful-fs/package.json b/node_modules/graceful-fs/package.json index 4f513626d53..30f4c40bad1 100644 --- a/node_modules/graceful-fs/package.json +++ b/node_modules/graceful-fs/package.json @@ -6,7 +6,7 @@ }, "name": "graceful-fs", "description": "fs monkey-patching to avoid EMFILE and other problems", - "version": "1.1.10", + "version": "1.1.14", "repository": { "type": "git", "url": "git://github.com/isaacs/node-graceful-fs.git" @@ -15,11 +15,9 @@ "engines": { "node": ">=0.4.0" }, - "devDependencies": {}, "directories": { "test": "test" }, - "dependencies": {}, "scripts": { "test": "tap test/*.js" }, @@ -32,6 +30,6 @@ ], "license": "BSD", "readme": "Just like node's `fs` module, but it does an incremental back-off when\nEMFILE is encountered.\n\nUseful in asynchronous situations where one needs to try to open lots\nand lots of files.\n", - "_id": "graceful-fs@1.1.10", + "_id": "graceful-fs@1.1.14", "_from": "graceful-fs@~1.1.1" }