Skip to content

fs.promises.readFile cannot read /proc/stat, produces empty result #21331

Closed
@constb

Description

@constb
  • Version: 10.4.1
  • Platform: Amazon Linux 2, kernel 4.14 x64
  • Subsystem: fs, experimental promises api
const fs = require('fs')
fs.promises.readFile('/proc/stat', { encoding: 'utf8' }).then(r => console.log(r.length)) // => 0
fs.readFile('/proc/stat', { encoding: 'utf8' }, (e, r) => console.log(r.length)) // => 2347
console.log(fs.readFileSync('/proc/stat', { encoding: 'utf8' }).length) // => 2347

I'm not sure how promises API differs from classic one, but this behaviour is surprising, and I can't find anything in the docs that would explain what I am doing wrong…

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.fsIssues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions