Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graceful-fs

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graceful-fs - npm Package Compare versions

Comparing version 1.1.9 to 1.1.10

test/open.js

32

graceful-fs.js

@@ -10,9 +10,7 @@ // this keeps a queue of opened file descriptors, and will make

var queue = []
, curOpen = 0
, constants = require("constants")
exports = module.exports = fs
fs._curOpen = 0
fs.MIN_MAX_OPEN = 64

@@ -43,3 +41,3 @@ fs.MAX_OPEN = 1024

if (curOpen >= fs.MAX_OPEN) {
if (fs._curOpen >= fs.MAX_OPEN) {
queue.push(new OpenReq(path, flags, mode, cb))

@@ -50,7 +48,7 @@ setTimeout(flush)

open(path, flags, mode, function (er, fd) {
if (er && er.code === "EMFILE" && curOpen > fs.MIN_MAX_OPEN) {
if (er && er.code === "EMFILE" && fs._curOpen > fs.MIN_MAX_OPEN) {
// that was too many. reduce max, get back in queue.
// this should only happen once in a great while, and only
// if the ulimit -n is set lower than 1024.
fs.MAX_OPEN = curOpen - 1
fs.MAX_OPEN = fs._curOpen - 1
return fs.open(path, flags, mode, cb)

@@ -64,8 +62,5 @@ }

cb = cb || noop
curOpen ++
fs._curOpen ++
originalOpen.call(fs, path, flags, mode, function (er, fd) {
if (er) {
onclose()
}
if (er) onclose()
cb(er, fd)

@@ -76,8 +71,12 @@ })

fs.openSync = function (path, flags, mode) {
curOpen ++
return originalOpenSync.call(fs, path, flags, mode)
var ret
try {
ret = originalOpenSync.call(fs, path, flags, mode)
fs._curOpen ++
} finally {}
return ret
}
function onclose () {
curOpen --
fs._curOpen --
flush()

@@ -87,8 +86,7 @@ }

function flush () {
while (curOpen < fs.MAX_OPEN) {
while (fs._curOpen < fs.MAX_OPEN) {
var req = queue.shift()
if (!req) break
if (!req) return
open(req.path, req.flags || "r", req.mode || 0777, req.cb)
}
if (queue.length === 0) return
}

@@ -95,0 +93,0 @@

@@ -5,3 +5,3 @@ {

"description": "fs monkey-patching to avoid EMFILE and other problems",
"version": "1.1.9",
"version": "1.1.10",
"repository": {

@@ -15,3 +15,18 @@ "type": "git",

},
"devDependencies": {}
"devDependencies": {},
"directories": {
"test": "test"
},
"dependencies": {},
"scripts": {
"test": "tap test/*.js"
},
"keywords": [
"fs",
"EMFILE",
"error",
"handling",
"monkeypatch"
],
"license": "BSD"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc