Skip to content

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

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to file-system APIs and the fs module.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions