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.52%. Comparing base (842448b) to head (d2e58e3).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61259      +/-   ##
==========================================
+ Coverage   88.00%   88.52%   +0.52%     
==========================================
  Files         704      704              
  Lines      208739   208741       +2     
  Branches    40196    40277      +81     
==========================================
+ Hits       183706   184794    +1088     
+ Misses      16992    15958    -1034     
+ Partials     8041     7989      -52     
Files with missing lines Coverage Δ
lib/internal/fs/glob.js 91.40% <100.00%> (+1.26%) ⬆️

... and 103 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.

@Han5991 Han5991 requested a review from Renegade334 January 9, 2026 04:39
Co-authored-by: René <contact.9a5d6388@renegade334.me.uk>
@Han5991 Han5991 force-pushed the fix/fs-glob-sync-enotdir branch from 285ded7 to d2e58e3 Compare January 9, 2026 04:59
@Renegade334 Renegade334 added request-ci Add this label to start a Jenkins CI on a PR. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Jan 9, 2026
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 9, 2026
@nodejs-github-bot
Copy link
Collaborator

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

Labels

commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. 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

3 participants