Skip to content

all versions of readdir don't work in recursive mode when used with a buffer argument #58892

@dario-piotrowicz

Description

@dario-piotrowicz

Version

All

Platform

All

Subsystem

fs

What steps will reproduce the bug?

Calling readdir with a Buffer argument and the recursive flag produces an ERR_INVALID_ARG_TYPE error

Image

Because of this join:

node/lib/fs.js

Line 1434 in 139c2e1

const resultPath = pathModule.join(currentPath, result[i]);

After that there are also some other joins that would kick in as well:


This happens with all version of readdir both the callback and promises versions (since they share the same code (referred by the above links)) as well as readdirSync (since that also uses the same processReaddirResult` utility the other two do)

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

Always

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

The expected behavior would be for the readdir functions not to error and return either an array of Buffers or Dirents (depending on options.withFileTypes)

This is the behavior described in the documentation:

What do you see instead?

Unexpected ERR_INVALID_ARG_TYPE errors are getting thrown

Additional information

This issue is the equivalent to #58634 but for readdir

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.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