-
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
process.stdout/stderr.isTTY undefined in worker_thread #26946
Comments
// cc @addaleax |
IMO it make sense for We could copy the |
Same also applies to child processes, fwiw: #2333. |
@silverwind For As a (temporary) workaround, we can set const { workerData } = require('worker_threads')
if (workerData.isTTY) {
for (const stream of ['stdout', 'stdin', 'stderr']) {
if (process[stream].isTTY === undefined) {
process[stream].isTTY = true
}
}
} |
I'm going to close this out. It's working as expected as far as I'm concerned and 343ddff adds hints to the documentation. |
@bnoordhuis It would be useful to be able to know whether the main thread is TTY though. When you know you don't need things that are unsupported. For example, it could be useful to decide whether to print ANSI colors from the worker thread. Could Node.js somehow expose to the worker thread whether stdout/stderr in the main thread is TTY? |
In worker threads,
process.stdout.isTTY
andprocess.stderr.isTTY
areundefined
.I am not sure if this is intended behavior or not, but I found it while looking into why supports-color reports that color is not supported from worker threads (see chalk/supports-color#97). If I ignore the isTTY flag, then color output does seem to work correctly.
The text was updated successfully, but these errors were encountered: