Skip to content

fs.promises.readdir( path, { withFileTypes: true } ) errorΒ #22829

@jackschmidt

Description

@jackschmidt

I would expect the following to run without error

fs.promises.readdir( ".", { withFileTypes: true } ).
then( ret => console.log({ret}), err => console.log({err}) );

and produce output similar to that of:

fs.readdir( ".", { withFileTypes : true },
(err,ret) => err ? console.log({err}) : console.log({ret}) );

However, the promise version prints this instead:

{ err:
   TypeError: Cannot assign to read only property '0' of string '.git'
       at getDirents (internal/fs/utils.js:143:18)
       at Promise (internal/util.js:276:30)
       at new Promise (<anonymous>)
       at getDirents (internal/util.js:275:12)
       at Object.readdir (internal/fs/promises.js:305:5) }

The problem happens when compiled from source or when installed from apt:

Package: nodejs
Version: 10.10.0-1nodesource1
Maintainer: Chris Lea <chl@nodesource.com>

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.promisesIssues and PRs related to ECMAScript promises.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions