Open
Conversation
Filesystem operations can return EAGAIN to indicate a temporary resource unavailability. This is similar to EMFILE/ENFILE but was not being retried by graceful-fs, causing spurious failures in tools like pnpm. Add EAGAIN to the set of retryable error codes for open, readFile, writeFile, appendFile, copyFile, and readdir operations. The existing retry/backoff/timeout logic already handles this correctly - EAGAIN just needed to be recognized as a retryable condition. Fixes isaacs#258
Author
|
Friendly ping - any chance someone could take a look at this when they get a chance? Happy to make any changes if needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Filesystem operations can return
EAGAINto signal that the resource is temporarily unavailable and the caller should try again. This is a transient error similar toEMFILE/ENFILE, but graceful-fs wasn't retrying on it.This showed up in practice as spurious failures in pnpm (see pnpm/pnpm#9959) and other tools that rely on graceful-fs for resilient filesystem access.
The fix adds
EAGAINto the error code checks alongsideEMFILEandENFILEin all the async fs wrappers (open,readFile,writeFile,appendFile,copyFile,readdir). The existing retry queue with exponential backoff and 60s timeout handles the rest --EAGAINjust needed to be recognized as a retryable condition.Note that
polyfills.jsalready hadEAGAINhandling for the lower-levelfs.read/fs.readSync, so this brings the higher-level operations in line.Tests added:
All existing tests continue to pass.
Fixes #258