Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Cross-Platform
  3. graceful-fs

graceful-fs

BlueOak-1.0.0JavaScript

A drop-in replacement for Node.js fs module that handles EMFILE errors gracefully with queuing and retries.

GitHubGitHub
1.3k stars150 forks0 contributors

What is graceful-fs?

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.

Target Audience

Node.js developers building applications that perform intensive filesystem operations, especially those running on Windows with antivirus software or systems with file descriptor limits.

Value Proposition

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.

Overview

fs with incremental backoff on EMFILE

Use Cases

Best For

  • Applications that open many files simultaneously and risk hitting EMFILE/ENFILE errors from too many file descriptors.
  • Windows-based Node.js applications where antivirus software frequently locks files and blocks rename operations.
  • Cross-platform projects requiring consistent filesystem behavior across different operating systems and Node.js versions.
  • Legacy Node.js applications that need compatibility with older versions (pre-0.6.2) for methods like lchmod.
  • Applications where non-root users encounter EINVAL/EPERM errors during chown operations that should be ignored.
  • Projects using synchronous filesystem methods that cannot be automatically patched for EMFILE errors, requiring manual error handling.

Not Ideal For

  • Performance-critical applications where file I/O latency must be minimized, as queuing introduces delays.
  • Projects relying heavily on synchronous fs methods, since graceful-fs does not handle EMFILE errors for sync calls.
  • Libraries or modules that should avoid patching global fs to prevent side-effects on dependent code.
  • Environments requiring strict dependency stability, as major version changes can be breaking due to subtle behavior shifts.

Pros & Cons

Pros

Robust Error Handling

Automatically queues open and readdir calls on EMFILE errors, retrying them after file closures to prevent application crashes from too many open files.

Windows Antivirus Workaround

Retries rename operations for up to one second when blocked by antivirus software on Windows, reducing failures in common real-world scenarios.

Cross-Platform Consistency

Normalizes behavior for methods like lchmod and lutimes across different Node.js versions and operating systems, ensuring reliable filesystem access.

Non-Root User Tolerance

Ignores EINVAL and EPERM errors in chown operations for non-root users, avoiding unnecessary failures in permission-sensitive environments.

Cons

Sync Method Incompatibility

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.

Performance Overhead

Trades EMFILE errors for slower filesystem operations by queuing requests, which can introduce latency not acceptable in high-performance applications.

Patching Side-Effects

Global patching via gracefulify can cause unexpected delays and behavior changes if used in libraries, as warned in the README caveats.

Frequently Asked Questions

Quick Stats

Stars1,303
Forks150
Contributors0
Open Issues28
Last commit6 months ago
CreatedSince 2011

Tags

#retry-logic#filesystem#nodejs#error-handling#cross-platform#drop-in-replacement

Built With

N
Node.js

Included in

Cross-Platform1.2k
Auto-fetched 1 day ago

Related Projects

chokidarchokidar

Minimal and efficient cross-platform file watching library

Stars12,079
Forks621
Last commit4 months ago
fs-extrafs-extra

Node.js: extra methods for the fs object like copy(), remove(), mkdirs()

Stars9,618
Forks783
Last commit7 days ago
rimrafrimraf

A `rm -rf` util for nodejs

Stars5,842
Forks264
Last commit1 month ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub