Skip to content

fs: stat root exclude dirent from glob cwd#63538

Open
fallintoplace wants to merge 1 commit into
nodejs:mainfrom
fallintoplace:fix/glob-root-exclude-dirent-path
Open

fs: stat root exclude dirent from glob cwd#63538
fallintoplace wants to merge 1 commit into
nodejs:mainfrom
fallintoplace:fix/glob-root-exclude-dirent-path

Conversation

@fallintoplace
Copy link
Copy Markdown

Fixes #63535.

Summary

When globSync() applies a function exclude to the root path with withFileTypes: true, it synthesizes the Dirent from this.#cache.statSync(path). That lookup uses the ambient process.cwd() instead of the glob cwd, so the exclude callback can receive metadata for the wrong filesystem entry when those differ.

This updates the root exclude path to stat the resolved glob path and adds a regression test that exercises cwd !== process.cwd().

Validation

  • ran a targeted local repro that loads lib/internal/fs/glob.js under node --expose-internals
  • confirmed the current file passes and a one-line reverted variant fails with the wrong root parentPath

@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 May 24, 2026
@fallintoplace fallintoplace marked this pull request as ready for review May 24, 2026 14:40
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() uses process.cwd() when building the root exclude Dirent with withFileTypes

2 participants