Skip to content

Conversation

@Han5991
Copy link
Contributor

@Han5991 Han5991 commented Jan 3, 2026

fs.globSync failed with ENOTDIR when a path component in a glob pattern was a file but used as a directory (e.g., 'foo{,/bar}' when 'foo' is a file).

This change aligns getDirentSync with the asynchronous getDirent by wrapping the lstatSync call in a try-catch block to safely return null on such errors.

image

Fixes: #61257

`fs.globSync` failed with `ENOTDIR` when a path component in a glob
pattern was a file but used as a directory (e.g., 'foo{,/bar}' when
'foo' is a file).

This change aligns `getDirentSync` with the asynchronous `getDirent`
by wrapping the `lstatSync` call in a `try-catch` block to safely
return `null` on such errors.

Fixes: nodejs#61257
@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Jan 3, 2026
@codecov
Copy link

codecov bot commented Jan 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.54%. Comparing base (95852d7) to head (61bfdb3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61259      +/-   ##
==========================================
- Coverage   88.54%   88.54%   -0.01%     
==========================================
  Files         704      704              
  Lines      208753   208757       +4     
  Branches    40280    40286       +6     
==========================================
- Hits       184847   184836      -11     
- Misses      15907    15949      +42     
+ Partials     7999     7972      -27     
Files with missing lines Coverage Δ
lib/internal/fs/glob.js 91.42% <100.00%> (+0.04%) ⬆️

... and 39 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fs.globSync fails when fs.glob does not

2 participants