Skip to content

fs: apply function exclude to glob results#63049

Open
Kelpy2004 wants to merge 1 commit intonodejs:mainfrom
Kelpy2004:codex/fix-glob-function-exclude-results
Open

fs: apply function exclude to glob results#63049
Kelpy2004 wants to merge 1 commit intonodejs:mainfrom
Kelpy2004:codex/fix-glob-function-exclude-results

Conversation

@Kelpy2004
Copy link
Copy Markdown

Function-form exclude callbacks were applied while queuing subpatterns, but some terminal result paths were added directly to the result set. That meant files matched by terminal ** or terminal child patterns could bypass an exclude(path) callback that matched the full relative path.

For example, globSync('**', { cwd, exclude: (path) => path === 'a/skip.txt' }) could still include a/skip.txt.

This routes result additions through a shared helper that applies function-form excludes before recording sync and async glob results, while preserving the existing array-exclude filtering in ResultSet.

Added coverage for:

  • fs.globSync()
  • callback fs.glob()
  • fs.promises.glob()
  • terminal ** results
  • terminal pattern results

Validation performed locally:

  • node --check lib/internal/fs/glob.js
  • node --check test/parallel/test-fs-glob.mjs
  • standalone reproduction against installed Node v24.11.1 confirmed the pre-fix behavior still returns an excluded nested file

I could not run the patched Node test binary because this sparse checkout does not include a built local node executable.

@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 Apr 30, 2026
@Kelpy2004 Kelpy2004 force-pushed the codex/fix-glob-function-exclude-results branch from 4882cfd to de11752 Compare May 1, 2026 13:20
@Kelpy2004
Copy link
Copy Markdown
Author

I pushed an update that adds coverage for withFileTypes: true as well, so the regression tests now cover string and Dirent result paths across fs.globSync(), callback fs.glob(), and fs.promises.glob().

The currently visible GitHub Actions runs are all action_required, which means they are waiting for maintainer approval to run on this forked PR rather than failing due to test output.

Local validation:

  • node --check lib/internal/fs/glob.js
  • node --check test/parallel/test-fs-glob.mjs
  • standalone reproduction against installed Node v24.11.1 still shows the pre-fix bug (exclude does not remove a nested terminal ** result)

@Kelpy2004
Copy link
Copy Markdown
Author

@mcollina when you have a moment, could you please take a look at this fs.glob fix? It builds on the recent followSymlinks glob work and covers the function-form exclude callback being bypassed for terminal results.

The GitHub Actions runs are currently waiting for maintainer approval on this forked PR, so a review/CI approval would be appreciated. Happy to adjust the patch if you prefer a different shape before merge.

Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label May 5, 2026
@Kelpy2004 Kelpy2004 force-pushed the codex/fix-glob-function-exclude-results branch from de11752 to 88d0ea5 Compare May 5, 2026 10:39
@Kelpy2004 Kelpy2004 requested a review from mcollina May 5, 2026 10:47
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 5, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.68%. Comparing base (4744070) to head (e3e82a2).
⚠️ Report is 110 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63049      +/-   ##
==========================================
+ Coverage   89.66%   89.68%   +0.02%     
==========================================
  Files         706      713       +7     
  Lines      219370   224146    +4776     
  Branches    42065    42324     +259     
==========================================
+ Hits       196694   201028    +4334     
- Misses      14586    14952     +366     
- Partials     8090     8166      +76     
Files with missing lines Coverage Δ
lib/internal/fs/glob.js 91.90% <100.00%> (+0.41%) ⬆️

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

@Kelpy2004 Kelpy2004 force-pushed the codex/fix-glob-function-exclude-results branch from 88d0ea5 to f8c0188 Compare May 5, 2026 16:54
Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label May 5, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 5, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Signed-off-by: Aryan Katiyar <aryankatiyar613@gmail.com>
@Kelpy2004 Kelpy2004 force-pushed the codex/fix-glob-function-exclude-results branch from f8c0188 to e3e82a2 Compare May 6, 2026 15:33
@Kelpy2004
Copy link
Copy Markdown
Author

@mcollina the two remaining GitHub Actions failures look unrelated to this patch:

  • test-macOS passed the normal test step, then failed only in the unusual-path rerun on parallel/test-debugger-help with Timeout (15000) while waiting for /break (?:on start )?in/i.
  • coverage-linux-without-intl failed in Report JS because global coverage was 94.99% against the 95% threshold. The hidden failures in that run were test-code-cache, test-inspector-wait-for-connection, and test-vm-source-text-module-leak, none related to fs.glob.

Codecov reports the modified lib/internal/fs/glob.js lines are covered at 100.00%.
Could you please rerun those two jobs?

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.

4 participants