Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
constb opened this issue Jun 14, 2018 · 2 comments
Closed

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

constb opened this issue Jun 14, 2018 · 2 comments
Labels
confirmed-bug Issues with confirmed bugs. fs Issues and PRs related to the fs subsystem / file system.

Comments

@constb
Copy link

constb commented Jun 14, 2018

  • 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…

@fanyer
Copy link

fanyer commented Jun 21, 2018

same with me, the fs.promises interface return 0 when readFile /proc/stat .

  • Version: 10.4.1
  • Platform: Debian 9.4 linux 4.9.0.6 x64

@TimothyGu TimothyGu added confirmed-bug Issues with confirmed bugs. fs Issues and PRs related to the fs subsystem / file system. labels Jun 24, 2018
@TimothyGu
Copy link
Member

Can reproduce.

TimothyGu added a commit to TimothyGu/node that referenced this issue Jul 4, 2018
targos pushed a commit that referenced this issue Jul 4, 2018
PR-URL: #21497
Fixes: #21331
Refs: http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html
Refs: https://groups.google.com/forum/#!topic/nodejs-dev/rxZ_RoH1Gn0
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

No branches or pull requests

3 participants