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

Add API to worker thread to check whether main thread is TTY #51750

Open
sindresorhus opened this issue Feb 13, 2024 · 4 comments
Open

Add API to worker thread to check whether main thread is TTY #51750

sindresorhus opened this issue Feb 13, 2024 · 4 comments
Labels
feature request Issues that request new features to be added to Node.js. worker Issues and PRs related to Worker support.

Comments

@sindresorhus
Copy link

What is the problem this feature will solve?

In worker threads, process.stdout.isTTY and process.stderr.isTTY are undefined. However, they do forward stdout/stderr to the main thread, and the main thread could potentially be isTTY === true. This makes sense as some things don't work, like raw mode. However, things that produce colors would want to be able to detect that the main thread is TTY, so colors can be shown when logged from a worker thread.

What is the feature you are proposing to solve the problem?

Add an API to worker threads to check whether stdout/stderr in the main thread is TTY.

This is needed for color packages like chalk to be able to support showing colors when running in worker threads.

Relevant issue: #26946

What alternatives have you considered?

No response

@sindresorhus sindresorhus added the feature request Issues that request new features to be added to Node.js. label Feb 13, 2024
@marco-ippolito
Copy link
Member

marco-ippolito commented Feb 14, 2024

would a solution like explicity setting in the worker options new Worker(__filename, { isTTY: true }) work?
And on the other side workerData.isTTY.
It doesnt seem high effort

@sindresorhus
Copy link
Author

That doesn't work for my use-case, where a package needs this. The package has no control over the worker creation.

Copy link
Contributor

There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the never-stale Mark issue so that it is never considered stale label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot added the stale label Aug 13, 2024
@sindresorhus
Copy link
Author

Please keep this open.

@github-actions github-actions bot removed the stale label Aug 14, 2024
@RedYetiDev RedYetiDev added the worker Issues and PRs related to Worker support. label Aug 14, 2024
@RedYetiDev RedYetiDev moved this from Awaiting Triage to Triaged in Node.js feature requests Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. worker Issues and PRs related to Worker support.
Projects
Development

No branches or pull requests

3 participants