isaacs/node-graceful-fs — pull request #7 by jriecken (2012-05-04 02:42:51+00:00)
Title: Increment curOpen only after originalOpenSync succeeds

If an exception happens calling `fs.openSync`, the `curOpen` counter is incremented, but never decremented. This can cause asynchronous fs methods to hang if enough exceptions happen opening files synchronously.

E.g.

var fs = require('graceful-fs');

for(var i = 0; i < fs.MAX_OPEN; ++i) {
try {
fs.readFileSync('i-do-not-exist');
} catch(e) {}
}

// This readFile is queued up because curOpen == fs.MAX_OPEN, but it never gets executed
fs.readFile(__filename, function(e, contents) {
console.log('This callback should be called');
});