-
Notifications
You must be signed in to change notification settings - Fork 30k
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
tty.isatty(1) and process.stdout.isTTY in worker_threads worker return different values #28386
Comments
See #26946 (comment) |
Thanks for the link, interesting. But it doesn't say anything about |
@1999 This still seems like expected behaviour – fd’s are per-process, so fd |
@addaleax I didn't know that |
You're welcome to open a documentation pull request but where would you add it? There are tens if not hundreds of core methods that accept a file descriptor. It'd be incongruent to single out Its behavior also isn't the least bit surprising to me but maybe that's just me. |
For me as a Node.JS developer, it's not clear if I should use |
I’m having the same issue as Ben here – I don’t see a good place in the documentation that isn’t “everywhere”…
We could document that |
i think the question is more like (@1999 correct me if i'm wrong) when should someone be dealing with fd 1 vs when should someone be dealing with process.stdout. |
Exactly. |
I would think of the fd-handling functions as low-level primitives that are there for when you really need them, but generally dealing with the corresponding JS objects makes more sense when available (e.g. 99 % of the time using In the case of Is that helpful? Is that something that we could or should document in some way? |
it's also worth noting that accessing process.std{out, in, err} can change their modes and that node will start processing data (which may or may not be a good thing depending on your use case) |
Related to this, we may want to properly publicly (think, docs) expose |
Fixes: nodejs#28386 Refs: nodejs#31292 Refs: nodejs/help#2136
Fixes: #28386 Refs: #31292 Refs: nodejs/help#2136 PR-URL: #31395 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Fixes: #28386 Refs: #31292 Refs: nodejs/help#2136 PR-URL: #31395 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Fixes: #28386 Refs: #31292 Refs: nodejs/help#2136 PR-URL: #31395 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
I found out recently that in a worker which is run with
worker_threads
,tty.isatty(1)
returns True whereasprocess.stdout.isTTY
returns False.This led to a weird issue in
mocha
- a popular library for testing: mochajs/mocha#3955The text was updated successfully, but these errors were encountered: