isaacs / node-graceful-fs

fs with incremental backoff on EMFILE
ISC License
1.27k stars 148 forks source link

dont forget to retry #217

Closed nlf closed 3 years ago

nlf commented 3 years ago

if a user is only running one fs operation at a time, and that operation fails with an EMFILE, we never call their callback. because of that the event loop no longer has anything to do and the entire process silently exits.

this change makes it so we start retrying an operation immediately, rather than waiting for another operation to finish successfully or fs.close/fs.closeSync to be called. in the callbacks for those, we now reset all state for everything in the queue and make sure the retry loop is running, this will make sure things retry sooner if they can.

the retry now keeps running every tick until the queue is empty. items are removed from the queue either when we retry them, or when they've reached a maximum of 60 seconds. this corrects the contract so that we will not stop trying to process the queue until every item in it has had its callback fired one way or another.

ljharb commented 3 years ago

The merged commit seems to contain some changes that aren't present in this PR, which cause graceful-fs to suddenly start breaking in node <= 4: https://github.com/isaacs/node-graceful-fs/commit/e4ee5d6b4c3bd193d78499261e273c811f36b312#r54480099