Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Increment curOpen only after originalOpenSync succeeds #7

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants

jriecken commented May 4, 2012

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');
});

+1

Really, my express application doesn't want to work without this pull request.
I use universl-jst, that use node-glob thtat use graceful-js.

mojit0 commented Jul 28, 2012

Seems this is the same/related issue to the recent patch available in the latest release.

Good to know that it finally got fixed.

@jriecken jriecken closed this Jul 30, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment