Skip to content

readdirSync cannot read files properly when using { recursive: true, withFileTypes: true } #51773

@prfd

Description

@prfd

Version

v18.17.1

Platform

No response

Subsystem

fs

What steps will reproduce the bug?

mkdir -p test/include
touch test/libvips-cpp.so.42
const fs = require('fs');
fs.readdirSync('test', {recursive: true, withFileTypes: true});

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

await fs.promises.readdir('test', {recursive: true, withFileTypes: true})
[
  Dirent { name: 'include', path: 'folder', [Symbol(type)]: 2 },
  Dirent {
    name: 'libvips-cpp.so.42',
    path: 'folder',
    [Symbol(type)]: 1
  }
]

What do you see instead?

[
  Dirent { name: 'include', path: 'folder', [Symbol(type)]: 2 },
  Dirent {
    name: 'libvips-cpp.so.42',
    path: 'folder',
    [Symbol(type)]: 1
  },
  Dirent {
    name: undefined,
    path: 'folder/include',
    [Symbol(type)]: undefined
  },
  Dirent {
    name: undefined,
    path: 'folder/include',
    [Symbol(type)]: undefined
  }
]

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions