Skip to content

fix: set Dirent.parentPath in asar fs.readdir withFileTypes - #52506

Merged
ckerr merged 1 commit into
42-x-yfrom
trop/42-x-y-bp-fix-set-dirent-parentpath-in-asar-fs-readdir-withfiletypes-1785284706755
Jul 29, 2026
Merged

fix: set Dirent.parentPath in asar fs.readdir withFileTypes#52506
ckerr merged 1 commit into
42-x-yfrom
trop/42-x-y-bp-fix-set-dirent-parentpath-in-asar-fs-readdir-withfiletypes-1785284706755

Conversation

@trop

@trop trop Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Backport of #51845

See that PR for details.

Notes: Fixed Dirent.parentPath being undefined for fs.readdir, fs.readdirSync, fs.glob, and fs.globSync with withFileTypes: true inside asar archives.

The asar fs wrapper built Dirent objects with `new fs.Dirent(name, type)`
in the non-recursive readdir handlers, which left `parentPath` undefined.
As a result `Dirent.parentPath` was missing for `fs.readdir` /
`readdirSync` (and for `fs.glob` / `globSync`, which read directories
through these handlers) when operating inside an asar archive, while it
was correctly populated outside of asar and on the recursive readdir
code path.

Use the internal `getDirent(path, name, type)` helper instead, matching
both the recursive readdir path and Node's own behavior, so `parentPath`
is set to the directory that was read.

Fixes #51838

Co-authored-by: Sanidhya Singh <singhsanidhya741@gmail.com>
@trop trop Bot added 42-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Jul 29, 2026
@ckerr
ckerr merged commit 0f3d4d8 into 42-x-y Jul 29, 2026
78 checks passed
@ckerr
ckerr deleted the trop/42-x-y-bp-fix-set-dirent-parentpath-in-asar-fs-readdir-withfiletypes-1785284706755 branch July 29, 2026 02:19
@release-clerk

release-clerk Bot commented Jul 29, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed Dirent.parentPath being undefined for fs.readdir, fs.readdirSync, fs.glob, and fs.globSync with withFileTypes: true inside asar archives.

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

Labels

42-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant