Skip to content

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

Closed
@jackschmidt

Description

@jackschmidt
  • Version: v10.10.0
  • Platform: Linux hostname 4.15.0-33-generic docs: re-word project messaging #36-Ubuntu SMP Wed Aug 15 16:00:05 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: fs

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