Skip to content

fs: readDir {withFileTypes: true} could call callback more than once #22778

Closed
@ajafff

Description

@ajafff
  • Version: 10.10.0
  • Platform:
  • Subsystem: fs

While looking through the code of readDir's new option withFileTypes I noticed that getDirents unconditionally calls the callback in case of an error:

if (err) {
callback(err);
return;
}

If more than one file is of type UV_DIRENT_UNKNOWN and fs.stat returns with an error for more than one of these files, the callback will be called more than once. That could lead to unexpected behavior for API users.

I don't know if that needs to be fixed as the scenario seems very unlikely, but I thought I should at least report it.

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