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 thread option #1030

Open
ehmicky opened this issue May 8, 2024 · 2 comments
Open

Add thread option #1030

ehmicky opened this issue May 8, 2024 · 2 comments

Comments

@ehmicky
Copy link
Collaborator

ehmicky commented May 8, 2024

Being able to spawn a worker thread instead of a child process using a simple boolean option would be nice.

await execa(..., {thread: true});

Unlike Worker in browsers, Node.js worker_threads includes many similar features as child processes: environment variables, stdin/stdout/stderr, argv.

Also, most of Execa's logic is actually userland, i.e. implemented by us and not borrowed from child_process.spawn(). For example, most things input/output-related (including subprocess piping), the verbose mode, etc. It would be nice to be able to re-use all of those Execa features but with a worker thread instead. I believe 90-95% of features can be re-used.

This option would imply the node: true option, since only Node.js files can be launched as threads.

Instead of returning a .subprocess property (#413), this would return a .worker property, with the Worker instead. We would try to make the properties/methods as close to .subprocess as possible, for parity.

That's a bigger feature, but this might be quite useful. What are your thoughts on this @sindresorhus?

@sindresorhus
Copy link
Owner

This sounds useful indeed. I am a little bit worried about the growing complexity, but if we really can reuse most of the code, it's not too bad.

However, I think it would be better to wait a bit for this, to ensure v9 is stable first.

@ehmicky
Copy link
Collaborator Author

ehmicky commented May 28, 2024

Sounds good. 👍

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

No branches or pull requests

2 participants