Skip to content

fs: recursive option is incompatible with encoding #60564

@ChALkeR

Description

@ChALkeR

Found while looking at #60559

Both options are documented, and it's not mentioned that they can't be combined

> fs.readdirSync('.', { recursive: true, encoding: 'buffer' })
Uncaught:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Buffer
    at Object.join (node:path:1339:7)
    at handleFilePaths (node:fs:1421:35)
    at processReaddirResult (node:fs:1400:92)
    at read (node:fs:1460:5)
    at readdirSyncRecursive (node:fs:1468:5)
    at Object.readdirSync (node:fs:1542:12) {
  code: 'ERR_INVALID_ARG_TYPE'
}
> await fs.promises.readdir('.', { recursive: true, encoding: 'buffer' })
Uncaught:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Buffer
    at Object.join (node:path:1339:7)
    at readdirRecursive (node:internal/fs/promises:920:39)
    at async REPL3:1:33 {
  code: 'ERR_INVALID_ARG_TYPE'
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions