Repository navigation
fix: Ensure walk() doesn't error out on directory ENOENT - #135
Merged
Merged
Conversation
Merged
2 of 9 tasks
nzakas
added a commit
that referenced
this pull request
Sep 9, 2026
`NodeHfsImpl#list()` and `DenoHfsImpl#list()` are async generators, so the directory isn't actually read until the iterator is first advanced. The ENOENT handling added in #135 only wrapped the call to `list()`, so an ENOENT thrown during iteration (e.g. a directory deleted between being discovered and being listed) escaped `walk()`. `walk()` now drives the `list()` iterator manually, catching ENOENT from `next()` and stopping the walk of that directory, while still rethrowing other errors and closing the iterator on early exit. Fixes #154 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019DHXVwqQ4iawKrV2DxPVKV
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.
What is the purpose of this pull request?
Ensures that
walk()doesn't error out on ENOENT errors. Due to the asynchronous nature of listing directory entries, it's possible that a directory may have been deleted beforelist()is called on it.Other packages that do this:
glob- https://github.com/isaacs/node-glob/blob/main/src/processor.ts#L138fast-glob- https://github.com/mrmlnc/fast-glob/blob/master/src/providers/filters/error.ts#L18Refs eslint/eslint#18955
What changes did you make? (Give an overview)
This pull request includes changes to handle directory listing errors more gracefully in the
Hfsclass and adds corresponding tests to ensure the new behavior is correct. The most important changes include modifying thewalkmethod to handleENOENTerrors, updating the test suite to include a test for this new behavior, and importing necessary error classes.Error handling improvements:
packages/core/src/hfs.js: Modified thewalkmethod to catchENOENTerrors and return an empty array instead of throwing an error.Test suite updates:
packages/core/tests/hfs.test.js: Added a new test case to verify that thewalkmethod silently skips directories whenlist()throws anENOENTerror.packages/core/tests/hfs.test.js: ImportedNotFoundErrorfromerrors.jsto use in the new test case.