A drop-in replacement for Node.js fs module that handles EMFILE errors gracefully with queuing and retries.
graceful-fs is a Node.js module that replaces the built-in fs module with enhanced error handling and cross-platform normalization. It makes filesystem operations more resilient by automatically retrying failed operations and queuing requests when system limits are reached, prioritizing application stability over speed.
Node.js developers building applications that perform intensive filesystem operations, especially those running on Windows with antivirus software or systems with file descriptor limits.
Developers choose graceful-fs over the native fs module for its automatic handling of common filesystem errors (EMFILE, EACCESS, EAGAIN) and cross-platform consistency, preventing crashes from too many open files or antivirus interference without requiring manual error handling.
fs with incremental backoff on EMFILE
Automatically queues open and readdir calls on EMFILE errors, retrying them after file closures to prevent application crashes from too many open files.
Retries rename operations for up to one second when blocked by antivirus software on Windows, reducing failures in common real-world scenarios.
Normalizes behavior for methods like lchmod and lutimes across different Node.js versions and operating systems, ensuring reliable filesystem access.
Ignores EINVAL and EPERM errors in chown operations for non-root users, avoiding unnecessary failures in permission-sensitive environments.
Cannot intercept or handle EMFILE/ENFILE errors for synchronous fs methods, requiring developers to manually handle errors in sync code, as noted in the README.
Trades EMFILE errors for slower filesystem operations by queuing requests, which can introduce latency not acceptable in high-performance applications.
Global patching via gracefulify can cause unexpected delays and behavior changes if used in libraries, as warned in the README caveats.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.