-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
doc: explain process.stdout in worker_threads #31292
Conversation
@@ -289,6 +289,10 @@ The `tty.isatty()` method returns `true` if the given `fd` is associated with | |||
a TTY and `false` if it is not, including whenever `fd` is not a non-negative | |||
integer. | |||
|
|||
Within `worker_threads`, this API will return `false` for process.stdout. | |||
This is because the `process.stdout` of the worker is a pipe into the parent, | |||
not actually a TTY. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not accurate:
> void new Worker(`console.log('isatty(1)', require('tty').isatty(1))`, {eval:true})
undefined
> isatty(1) true
tty.isatty()
is generally not concerned with what thread it’s being called on, as fd
s are a process-wide resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@addaleax , I am describing fd 1
, instead process.stdout.fd
void new Worker(`console.log('isatty(process.stdout.fd)', require('tty').isatty(process.stdout.fd))`, {eval:true})
undefined
satty(process.stdout.fd) false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: I am describing fd 1 -> I am NOT describing fd 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
process.stdout.fd
is undefined
in a worker thread. (Should it be?)
> void new Worker('console.log("fd:", process.stdout.fd)', {eval: true})
undefined
> fd: undefined
@HarshithaKP Feel free to re-open (or request that it be re-opened if the interface won't let you do it) if you plan on continuing to work on this. It seems to me that the proper place for the documentation would be inside the |
@Trott , why did you close this ? This API ( |
Because this doesn't seem like the right approach and I thought (wrongly?) that seemed to be pretty clear. (We have over 200 open PRs so I also thought maybe it's not a bad thing to be a little more efficient about closing ones that may be stalled. They're easy enough to re-open.)
I don't think it exhibits uncommon behavior. If |
And now that I think more about it, is that a bug? |
So, to summarize: In a main thread, In a worker thread, Which leads us to the questions:
|
Separate issue: The |
Looks like it does not coerce and simply returns false. (Only messed around a little in the REPL, didn't look at the code so I could still be wrong.) Whatever the actual case it, it should be documented, I imagine. |
Yes. I think there’s an open issue about documenting these, and removing them is not a viable option at any point in Node’s future anyway, I imagine.
No. |
@HarshithaKP I’d open a new PR, since it”s unrelated to the contents of this PR. |
Closing this as this is unrelated to the contents of PR. |
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>
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
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes