[Bug?]: fs.rm
is broken with recursive option in yarn 3 pnp, node >= 20.12.0
#6247
Labels
bug
Something isn't working
Self-service
Describe the bug
When using
fs.rm
withrecursive: true
(or its sync, async versionrmSync
andfs/promises#rm
), there's an error ofTypeError [ERR_INVALID_ARG_TYPE]: The "list[2]" argument must be an instance of Buffer or Uint8Array. Received type string
.To reproduce
yarn node test.js
Environment
Additional context
I found this doesn't happen on node 18.
recursive
option of fs.rm usesreaddirSync
, and on Node 18 we use pure node fs module but on Node 20 we use pnp patched version.This error happens when the patched
readdirSync
is used internally, by converting the result from Buffer to string withNodePathFS.mapToBase
. It also means that pnp patchedreaddirSync
does not respect theencoding
option, which isbuffer
in internal/fs/rimraf. According to Node.js Docs if the encoding option set tobuffer
, the result should be an array of buffer.The text was updated successfully, but these errors were encountered: