Version
All
Platform
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

Because of this join:
|
const resultPath = pathModule.join(currentPath, result[i]); |
After that there are also some other joins that would kick in as well:
|
const direntPath = pathModule.join(path, dirent.name); |
|
const direntPath = pathModule.join(path, ent); |
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
Version
All
Platform
Subsystem
fs
What steps will reproduce the bug?
Calling
readdirwith a Buffer argument and therecursiveflag produces anERR_INVALID_ARG_TYPEerrorBecause of this
join:node/lib/fs.js
Line 1434 in 139c2e1
After that there are also some other
joins that would kick in as well:node/lib/internal/fs/promises.js
Line 897 in 139c2e1
node/lib/internal/fs/promises.js
Line 918 in 139c2e1
This happens with all version of
readdirboth the callback and promises versions (since they share the same code (referred by the above links)) as well asreaddirSync(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
readdirfunctions not to error and return either an array ofBuffers orDirents (depending onoptions.withFileTypes)This is the behavior described in the documentation:
readdirdocs (permalink)fsPromises.readdirdocs (permalink)readdirSyncdocs (permalink)What do you see instead?
Unexpected
ERR_INVALID_ARG_TYPEerrors are getting thrownAdditional information
This issue is the equivalent to #58634 but for
readdir