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

Async iterator on process.stdin not working correctly? #22044

Closed
tlrobinson opened this issue Jul 31, 2018 · 2 comments
Closed

Async iterator on process.stdin not working correctly? #22044

tlrobinson opened this issue Jul 31, 2018 · 2 comments
Labels
stream Issues and PRs related to the stream subsystem.

Comments

@tlrobinson
Copy link

tlrobinson commented Jul 31, 2018

Version: v10.7.0
Platform: Darwin x.local 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: process

I'm aware async iteration on streams is experimental, and perhaps I'm doing something wrong, but the following just returns without printing anything after you type the first new line (or the first character if you process.stdin.setRawMode(true)):

(async function() {
  for await (const chunk of process.stdin) {
    process.stdout.write(chunk);
  }
})()

However it works correctly if you pipe something to the process. Also, it does work correctly if you use fs.createReadStream("/dev/stdin") instead of process.stdin:

const fs = require("fs");
(async function() {
  for await (const chunk of fs.createReadStream("/dev/stdin")) {
    process.stdout.write(chunk);
  }
})()

Besides this, async iteration of streams is great!

@vsemozhetbyt vsemozhetbyt added the stream Issues and PRs related to the stream subsystem. label Jul 31, 2018
@Jamesernator
Copy link

The cause of this is most likely the same as in #20503 , although thanks for an interesting workaround by using /dev/stdin as I hit this issue recently.

@addaleax
Copy link
Member

addaleax commented Sep 2, 2018

Looks like this has been fixed in fe47b8b as well. Thanks for the bug report!

@addaleax addaleax closed this as completed Sep 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants