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 returns 0 bytes from /dev/fd/NNN #22391

Closed
andrewdotn opened this issue Aug 18, 2018 · 2 comments
Closed

fs.promises.readFile returns 0 bytes from /dev/fd/NNN #22391

andrewdotn opened this issue Aug 18, 2018 · 2 comments
Labels
fs Issues and PRs related to the fs subsystem / file system.

Comments

@andrewdotn
Copy link
Contributor

  • Version: v10.6.0
  • Platform: Linux localhost 3.10.0-862.6.3.el7.x86_64 #1 SMP Tue Jun 26 16:32:21 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux and Darwin localhost 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64
  • Subsystem: fs.promises

The <(cmd) process substitution shell feature runs a command and passes its output to another command as a pipe named /dev/fd/NNN.

fs.promises.readFile returns a 0-length buffer when reading from that path.

$ cat read-fd
console.log(process.argv[2])

const fs = require('fs');

if (process.argv[3] === 'callback') {
    fs.readFile(process.argv[2], (err, data) => {
        console.log(`err=${err} data=${data} datalen=${data.length}`);
    });
} else {
    fs.promises.readFile(process.argv[2]).then(d => console.log(d.length));
}
$ echo -n hello there > foo
$ node read-fd foo callback
foo
err=null data=hello there datalen=11
$ node read-fd foo
foo
(node:92585) ExperimentalWarning: The fs.promises API is experimental
11
$ node read-fd <(echo -n hello there) callback
/dev/fd/63
err=null data=hello there datalen=11
$ node read-fd <(echo -n hello there)
/dev/fd/63
(node:92592) ExperimentalWarning: The fs.promises API is experimental
0
@TimothyGu
Copy link
Member

This seems to be a duplicate of #21331. The fix, #21497, went out with v10.7.0. Could you test and confirm?

@TimothyGu TimothyGu added the fs Issues and PRs related to the fs subsystem / file system. label Aug 18, 2018
@andrewdotn
Copy link
Contributor Author

andrewdotn commented Aug 18, 2018

Confirmed working on the latest version, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

No branches or pull requests

2 participants