Skip to content

fs: fix ENOTDIR in globSync when file is treated as dir - #61259

Merged
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
Han5991:fix/fs-glob-sync-enotdir
Jan 17, 2026
Merged

nodejs-github-bot merged 2 commits into
nodejs:mainfrom
Han5991:fix/fs-glob-sync-enotdir

Conversation

@Han5991

@Han5991 Han5991 commented Jan 3, 2026

Copy link
Copy Markdown
Contributor

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

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run. labels Jan 3, 2026
@codecov

codecov Bot commented Jan 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.53%. Comparing base (955d347) to head (4ddbabc).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #61259   +/-   ##
=======================================
  Coverage   88.52%   88.53%           
=======================================
  Files         704      704           
  Lines      208802   208804    +2     
  Branches    40318    40316    -2     
=======================================
+ Hits       184842   184856   +14     
+ Misses      15947    15925   -22     
- Partials     8013     8023   +10     
Files with missing lines Coverage Δ
lib/internal/fs/glob.js 91.40% <100.00%> (+0.02%) ⬆️

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

Comment thread lib/internal/fs/glob.js Resolved
@Han5991
Han5991 requested a review from Renegade334 January 9, 2026 04:39
@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. Only starts once the PR has an approving review. commit-queue-squash PRs the Commit Queue should land as one squashed commit. labels Jan 9, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jan 9, 2026
@nodejs-github-bot

This comment has been minimized.

@Han5991

Han5991 commented Jan 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the approval @Renegade334
It looks like there are some unrelated CI failures. Could you please trigger a re-run?

@Renegade334

Copy link
Copy Markdown
Member

Not until the security releases, no.

@Han5991

Han5991 commented Jan 11, 2026

Copy link
Copy Markdown
Contributor Author

Not until the security releases, no.

Understood. I'll wait until the security releases are out. Thanks for letting me know.

@Han5991

Han5991 commented Jan 16, 2026

Copy link
Copy Markdown
Contributor Author

Hello @Renegade334,
​Since the security releases are now out, could you please trigger the CI re-run?
​Thank you!

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@Renegade334 Renegade334 added the commit-queue PRs queued for automated landing through the Commit Queue. label Jan 17, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Jan 17, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/61259
✔  Done loading data for nodejs/node/pull/61259
----------------------------------- PR info ------------------------------------
Title      fs: fix ENOTDIR in globSync when file is treated as dir (#61259)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     Han5991:fix/fs-glob-sync-enotdir -> nodejs:main
Labels     fs, needs-ci, commit-queue-squash
Commits    3
 - fs: fix ENOTDIR in globSync when file is treated as dir
 - Merge branch 'nodejs:main' into fix/fs-glob-sync-enotdir
 - fs: simplify getDirentSync lstatSync handling
Committers 2
 - sangwook <bnbt3@naver.com>
 - GitHub <noreply@github.com>
PR-URL: https://github.com/nodejs/node/pull/61259
Fixes: https://github.com/nodejs/node/issues/61257
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/61259
Fixes: https://github.com/nodejs/node/issues/61257
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Sat, 03 Jan 2026 09:10:12 GMT
   ✔  Approvals: 1
   ✔  - René (@Renegade334): https://github.com/nodejs/node/pull/61259#pullrequestreview-3642642882
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2026-01-17T00:01:36Z: https://ci.nodejs.org/job/node-test-pull-request/70842/
- Querying data for job/node-test-pull-request/70842/
✔  Build data downloaded
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
✔  origin/main is now up-to-date
- Downloading patch for 61259
From https://github.com/nodejs/node
 * branch                  refs/pull/61259/merge -> FETCH_HEAD
✔  Fetched commits as 4f6759b738ef..d2e58e34df54
--------------------------------------------------------------------------------
error: commit 1d288a6411f9cfe9eca016109602fdc49ab25425 is a merge but no -m option was given.
fatal: cherry-pick failed
[main accf352996] fs: fix ENOTDIR in globSync when file is treated as dir
 Author: sangwook <bnbt3@naver.com>
 Date: Sat Jan 3 18:06:19 2026 +0900
 2 files changed, 26 insertions(+), 4 deletions(-)
   ✘  Failed to apply patches
https://github.com/nodejs/node/actions/runs/21089928816

@Han5991
Han5991 force-pushed the fix/fs-glob-sync-enotdir branch from d2e58e3 to ce80c92 Compare January 17, 2026 06:43
Han5991 and others added 2 commits January 17, 2026 15:45
`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
Co-authored-by: René <contact.9a5d6388@renegade334.me.uk>
@Han5991
Han5991 force-pushed the fix/fs-glob-sync-enotdir branch from ce80c92 to 4ddbabc Compare January 17, 2026 06:46
@Han5991

Han5991 commented Jan 17, 2026 •

Copy link
Copy Markdown
Contributor Author

@Renegade334 I've addressed the commit-queue-failed issue by rebasing onto main and removing the merge commits from the history. Everything should be clean now. Could you please take a look again?

Thank you!

@Renegade334

Copy link
Copy Markdown
Member

The CQ failure was because you don't have a public e-mail address on your GH profile. Bear in mind that any pushes to your branch will invalidate all the checks, so this will need to be re-run

@Renegade334 Renegade334 added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. and removed commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. labels Jan 17, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jan 17, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@Han5991

Han5991 commented Jan 17, 2026

Copy link
Copy Markdown
Contributor Author

@Renegade334 Thanks for letting me know about the missing email address. I've updated my profile settings to fix this. Thanks for your help as always.

@Renegade334 Renegade334 added the commit-queue PRs queued for automated landing through the Commit Queue. label Jan 17, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Jan 17, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 13a662f into nodejs:main Jan 17, 2026
66 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 13a662f

aduh95 pushed a commit that referenced this pull request Jan 20, 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.

Fixes: #61257
PR-URL: #61259
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jan 27, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [node](https://nodejs.org) ([source](https://github.com/nodejs/node)) | minor | `25.4.0` → `25.5.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>nodejs/node (node)</summary>

### [`v25.5.0`](https://github.com/nodejs/node/releases/tag/v25.5.0): 2026-01-26, Version 25.5.0 (Current), @&#8203;aduh95

[Compare Source](nodejs/node@v25.4.0...v25.5.0)

##### Notable Changes

- \[[`99a4e51f93`](nodejs/node@99a4e51f93)] - **crypto**: update root certificates to NSS 3.119 (Node.js GitHub Bot) [#&#8203;61419](nodejs/node#61419)
- \[[`fbe4da5725`](nodejs/node@fbe4da5725)] - **(SEMVER-MINOR)** **deps**: add LIEF as a dependency (Joyee Cheung) [#&#8203;61167](nodejs/node#61167)
- \[[`0feab0f083`](nodejs/node@0feab0f083)] - **(SEMVER-MINOR)** **deps**: add tools and scripts to pull LIEF as a dependency (Joyee Cheung) [#&#8203;61167](nodejs/node#61167)
- \[[`e91b296001`](nodejs/node@e91b296001)] - **(SEMVER-MINOR)** **fs**: add ignore option to fs.watch (Matteo Collina) [#&#8203;61433](nodejs/node#61433)
- \[[`b351910af1`](nodejs/node@b351910af1)] - **(SEMVER-MINOR)** **sea**: add `--build-sea` to generate SEA directly with Node.js binary (Joyee Cheung) [#&#8203;61167](nodejs/node#61167)
- \[[`957292e233`](nodejs/node@957292e233)] - **(SEMVER-MINOR)** **sea**: split sea binary manipulation code (Joyee Cheung) [#&#8203;61167](nodejs/node#61167)
- \[[`f289817ff8`](nodejs/node@f289817ff8)] - **(SEMVER-MINOR)** **sqlite**: enable defensive mode by default (Bart Louwers) [#&#8203;61266](nodejs/node#61266)
- \[[`069f3603e2`](nodejs/node@069f3603e2)] - **(SEMVER-MINOR)** **sqlite**: add sqlite prepare options args (Guilherme Araújo) [#&#8203;61311](nodejs/node#61311)
- \[[`5a984b9a09`](nodejs/node@5a984b9a09)] - **src**: use node- prefix on thread names (Stewart X Addison) [#&#8203;61307](nodejs/node#61307)
- \[[`75c06bc2a8`](nodejs/node@75c06bc2a8)] - **(SEMVER-MINOR)** **test**: migrate to `--build-sea` in existing SEA tests (Joyee Cheung) [#&#8203;61167](nodejs/node#61167)
- \[[`cabd58f1cb`](nodejs/node@cabd58f1cb)] - **(SEMVER-MINOR)** **test**: use fixture directories for sea tests (Joyee Cheung) [#&#8203;61167](nodejs/node#61167)
- \[[`ff1fcabfc9`](nodejs/node@ff1fcabfc9)] - **(SEMVER-MINOR)** **test\_runner**: support expecting a test-case to fail (Jacob Smith) [#&#8203;60669](nodejs/node#60669)

##### Commits

- \[[`778a56f3c9`](nodejs/node@778a56f3c9)] - **assert,util**: fix deep comparison for sets and maps with mixed types (Ruben Bridgewater) [#&#8203;61388](nodejs/node#61388)
- \[[`32cd18e37f`](nodejs/node@32cd18e37f)] - **async\_hooks**: enabledHooksExist shall return if hooks are enabled (Gerhard Stöbich) [#&#8203;61054](nodejs/node#61054)
- \[[`482b2568bc`](nodejs/node@482b2568bc)] - **benchmark**: add SQLite benchmarks (Guilherme Araújo) [#&#8203;61401](nodejs/node#61401)
- \[[`e9a34263bb`](nodejs/node@e9a34263bb)] - **buffer**: make methods work on Uint8Array instances (Neal Beeken) [#&#8203;56578](nodejs/node#56578)
- \[[`8255cdefcf`](nodejs/node@8255cdefcf)] - **build**: add `--shared-nbytes` configure flag (Antoine du Hamel) [#&#8203;61341](nodejs/node#61341)
- \[[`8dd379d110`](nodejs/node@8dd379d110)] - **build**: update android-patches/trap-handler.h.patch (Mo Luo) [#&#8203;60369](nodejs/node#60369)
- \[[`1b4b5eb0e4`](nodejs/node@1b4b5eb0e4)] - **build**: update devcontainer.json to use paired nix env (Joyee Cheung) [#&#8203;61414](nodejs/node#61414)
- \[[`86e2a763ad`](nodejs/node@86e2a763ad)] - **build**: infer cargo mode with gyp var build\_type directly (Chengzhong Wu) [#&#8203;61354](nodejs/node#61354)
- \[[`7e211e6942`](nodejs/node@7e211e6942)] - **build**: add embedtest into native suite (Joyee Cheung) [#&#8203;61357](nodejs/node#61357)
- \[[`637470e79f`](nodejs/node@637470e79f)] - **build**: fix misplaced comma in ldflags (hqzing) [#&#8203;61294](nodejs/node#61294)
- \[[`a1a0f77a45`](nodejs/node@a1a0f77a45)] - **build**: fix crate vendor file checksums on windows (Chengzhong Wu) [#&#8203;61329](nodejs/node#61329)
- \[[`d597b8e342`](nodejs/node@d597b8e342)] - **build,tools**: fix addon build deadlock on errors (Vladimir Morozov) [#&#8203;61321](nodejs/node#61321)
- \[[`b5cdc27ba4`](nodejs/node@b5cdc27ba4)] - **build,win**: improve logs when ClangCL is missing (Mike McCready) [#&#8203;61438](nodejs/node#61438)
- \[[`ef01f0c033`](nodejs/node@ef01f0c033)] - **build,win**: update WinGet configurations to Python 3.14 (Mike McCready) [#&#8203;61431](nodejs/node#61431)
- \[[`d8a1cdeefe`](nodejs/node@d8a1cdeefe)] - **child\_process**: treat ipc length header as unsigned uint32 (Ryuhei Shima) [#&#8203;61344](nodejs/node#61344)
- \[[`588b00fafa`](nodejs/node@588b00fafa)] - **cluster**: fix port reuse between cluster (Ryuhei Shima) [#&#8203;60141](nodejs/node#60141)
- \[[`99a4e51f93`](nodejs/node@99a4e51f93)] - **crypto**: update root certificates to NSS 3.119 (Node.js GitHub Bot) [#&#8203;61419](nodejs/node#61419)
- \[[`048f7a5c9c`](nodejs/node@048f7a5c9c)] - **deps**: upgrade npm to 11.8.0 (npm team) [#&#8203;61466](nodejs/node#61466)
- \[[`fbe4da5725`](nodejs/node@fbe4da5725)] - **(SEMVER-MINOR)** **deps**: add LIEF as a dependency (Joyee Cheung) [#&#8203;61167](nodejs/node#61167)
- \[[`0feab0f083`](nodejs/node@0feab0f083)] - **(SEMVER-MINOR)** **deps**: add tools and scripts to pull LIEF as a dependency (Joyee Cheung) [#&#8203;61167](nodejs/node#61167)
- \[[`4bb00d7e3c`](nodejs/node@4bb00d7e3c)] - **deps**: update googletest to [`8508785`](nodejs/node@8508785) (Node.js GitHub Bot) [#&#8203;61417](nodejs/node#61417)
- \[[`6a3c614f27`](nodejs/node@6a3c614f27)] - **deps**: update sqlite to 3.51.2 (Node.js GitHub Bot) [#&#8203;61339](nodejs/node#61339)
- \[[`13c0397d6d`](nodejs/node@13c0397d6d)] - **deps**: update icu to 78.2 (Node.js GitHub Bot) [#&#8203;60523](nodejs/node#60523)
- \[[`098ec6f196`](nodejs/node@098ec6f196)] - **deps**: update ada to v3.4.0 (Yagiz Nizipli) [#&#8203;61315](nodejs/node#61315)
- \[[`320b576125`](nodejs/node@320b576125)] - **deps**: update zlib to 1.3.1-e00f703 (Node.js GitHub Bot) [#&#8203;61135](nodejs/node#61135)
- \[[`98f5e7cf51`](nodejs/node@98f5e7cf51)] - **deps**: V8: cherry-pick [highway@`dcc0ca1`](https://github.com/highway/node/commit/dcc0ca1cd42) (Richard Lau) [#&#8203;61008](nodejs/node#61008)
- \[[`e326df79c9`](nodejs/node@e326df79c9)] - **deps**: V8: backport [`209d2db`](nodejs/node@209d2db9e24a) (Zhijin Zeng) [#&#8203;61322](nodejs/node#61322)
- \[[`ccfd9d9b30`](nodejs/node@ccfd9d9b30)] - **doc**: remove `v` prefix for version references (Mike McCready) [#&#8203;61488](nodejs/node#61488)
- \[[`b6cc5d77a1`](nodejs/node@b6cc5d77a1)] - **doc**: mention constructor comparison in assert.deepStrictEqual (Hamza Kargin) [#&#8203;60253](nodejs/node#60253)
- \[[`236d7ee635`](nodejs/node@236d7ee635)] - **doc**: add CVE delay mention (Rafael Gonzaga) [#&#8203;61465](nodejs/node#61465)
- \[[`0729fb6ee7`](nodejs/node@0729fb6ee7)] - **doc**: update previous version links in BUILDING (Mike McCready) [#&#8203;61457](nodejs/node#61457)
- \[[`0fb464252f`](nodejs/node@0fb464252f)] - **doc**: include OpenJSF handle for security stewards (Rafael Gonzaga) [#&#8203;61454](