Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

readline close not emitted if input is stdin #5307

Closed
belak opened this issue Apr 16, 2013 · 4 comments
Closed

readline close not emitted if input is stdin #5307

belak opened this issue Apr 16, 2013 · 4 comments

Comments

@belak
Copy link

belak commented Apr 16, 2013

I've been working with node.js a little and I'm trying to read some config values in through stdin on program start. This is what I came up with:

https://gist.github.com/anonymous/5392981

However, when running like the following, it only outputs "end", not "closed"

echo hello | node test.js

Adding terminal: false fixes it, but according to the docs this shouldn't be the case.
https://gist.github.com/gluxon/5393130

The docs say that any time input's "end" is triggered, readline's "close" should be.

Is this just something I'm missing, or is this an actual issue?

@hackedy
Copy link

hackedy commented Apr 16, 2013

I think this got introduced in PR #2922 (specifically commit aad12d0), but I'm not certain. I can verify that tomorrow.

Regardless of its origin, this needs a patch. (unless this is intended behavior 😞)

@bnoordhuis
Copy link
Member

It's because lib/readline.js checks if output.isTTY === true, which it always is for process.stdout, whether or not STDOUT_FILENO is actually a tty. It's a bug in lib/tty.js because it unconditionally sets WriteStream.prototype.isTTY = true

@jasnell
Copy link
Member

jasnell commented May 26, 2015

Unable to reproduce in v0.12 using the provided test case. Closing. Can reopen if new information is received.

@jasnell jasnell closed this as completed May 26, 2015
@belak
Copy link
Author

belak commented May 27, 2015

This does appear to work now. Thanks for the follow up!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants