Skip to content

fix: queue retries on EMFILE by routing default fs through @pnpm/fs.graceful-fs#54

Merged
zkochan merged 2 commits into
mainfrom
fix/11412
Apr 30, 2026
Merged

fix: queue retries on EMFILE by routing default fs through @pnpm/fs.graceful-fs#54
zkochan merged 2 commits into
mainfrom
fix/11412

Conversation

@zkochan
Copy link
Copy Markdown
Member

@zkochan zkochan commented Apr 30, 2026

Summary

  • Restores EMFILE retry/queueing for the default fs implementation by switching from native fs.promises to graceful-fs (promisified internally).
  • Custom fs injection (used by the test suite with memfs) still works via opts.fs.
  • Bumps version to 9.0.1.

Fixes pnpm/pnpm#11412.

Background

In 8.0.0 this package dropped graceful-fs in its ESM rewrite and switched to native fs.promises. fs.promises bypasses the userland patches that graceful-fs installs on the callback API, so under high concurrency (e.g. linking bins for hundreds of workspace projects in parallel) the writes surface EMFILE instead of waiting for a free file descriptor.

We re-add graceful-fs and call promisify(gfs.X) so the queueing applies to the promise API too — same pattern @pnpm/fs.graceful-fs uses, inlined here so this fix can ship without waiting on a @pnpm/fs.graceful-fs release.

Test plan

zkochan added 2 commits April 30, 2026 22:24
…raceful-fs

The ESM rewrite in 8.0.0 dropped graceful-fs and switched to native
fs.promises. fs.promises bypasses the userland patches graceful-fs
installs on the callback API, so under high concurrency (e.g. linking
bins for hundreds of workspace projects in parallel) the writes surface
EMFILE instead of waiting for a free file descriptor. This restores the
queueing behavior by defaulting to @pnpm/fs.graceful-fs, which exposes
promisify(gfs.X) wrappers that preserve graceful-fs's retry queue.

Custom fs injection (used by the test suite with memfs) still works via
opts.fs.

Closes pnpm/pnpm#11412.
Avoids the cross-repo release coordination needed for the @pnpm/fs.graceful-fs
chmod/unlink additions. Inlines the same promisify(gfs.X) wrapping pattern
that @pnpm/fs.graceful-fs uses to preserve graceful-fs's EMFILE retry queue
under the promise API.
@zkochan zkochan merged commit cc53370 into main Apr 30, 2026
4 of 6 checks passed
@zkochan zkochan deleted the fix/11412 branch April 30, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v11 EMFILE: too many open files on Windows

1 participant