fs: ignore deleted dirs in recursive watch scan#63686
Open
trivikr wants to merge 1 commit into
Open
Conversation
A recursively watched directory can be removed after a parent watcher observes it but before the non-native recursive watcher scans it. Ignore ENOENT from the directory scan so this deletion race does not emit an unhandled watcher error. Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: openai:gpt-5.5
MoLow
reviewed
Jun 1, 2026
MoLow
approved these changes
Jun 1, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #63686 +/- ##
=======================================
Coverage 90.34% 90.35%
=======================================
Files 732 732
Lines 236507 236529 +22
Branches 44531 44534 +3
=======================================
+ Hits 213684 213704 +20
- Misses 14525 14540 +15
+ Partials 8298 8285 -13
🚀 New features to boost your workflow:
|
Collaborator
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.
Fixes a race in the non-native recursive
fs.watch()implementation.When a directory is removed recursively, the watcher can observe the child
directory from the parent watcher and then attempt to scan it after it has
already been deleted. In that case,
readdirSync()throwsENOENT, which wasemitted as a watcher error and could crash tests with an unhandled
errorevent.
This treats
ENOENTduring the recursive directory scan as a normal deletionrace, while preserving existing error reporting for other failures.
Refs: https://github.com/nodejs/reliability/blob/main/reports/2026-06-01.md#jstest-failure
Example Error log
Assisted-by: openai:gpt-5.5