fix: propagate emptyDir directory read errors - #1080
Merged
RyanZim merged 1 commit intoSep 17, 2026
Merged
Conversation
RyanZim
approved these changes
Sep 10, 2026
RyanZim
left a comment
Collaborator
There was a problem hiding this comment.
Good catch, and thanks for submitting the PR!
One thing this will change is that if the specified path is a file, it will now error with ENOTDIR instead of EEXIST. This does make more sense, but I'm unsure if anyone is depending on this specific error code (i.e. should this be considered a breaking change?).
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix correctly preserves missing-directory behavior and comprehensively tests affected interfaces.
Pull request overview
Fixes emptyDir so only missing directories are created, while other read failures propagate unchanged.
Changes:
- Restricts recovery to
ENOENT. - Adds Promise, callback, and synchronous regression tests for
EACCESandEIO.
File summaries
| File | Description |
|---|---|
lib/empty/index.js |
Propagates non-ENOENT read errors. |
lib/empty/__tests__/empty-dir.test.js |
Tests Promise and callback error propagation. |
lib/empty/__tests__/empty-dir-sync.test.js |
Tests synchronous error propagation. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Collaborator
|
Published in v11.4.1 🎉 |
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.
emptyDir()andemptyDirSync()currently treat everyreaddirfailure as a missing directory. If the directory exists but cannot be read, recursivemkdircan succeed and the operation reports success without clearing anything.Only create the directory after
ENOENT; propagate other read errors unchanged. Add portable regression tests forEACCESandEIOin the Promise, callback, and synchronous interfaces. All five new tests fail before the fix; existing missing-directory tests still pass.Also reproduced on a real macOS directory with mode
000: the original implementation returns success with its file untouched, while the patch reportsEACCES.Validation:
npm testpasses (Standard lint, 737 unit tests with 8 existing skips, and ESM tests). The changed empty-directory module has 100% coverage.AI assistance: implemented and tested with OpenAI Codex.