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

Document more clearly that --require and --import can impact all threads and forked processes #52930

Closed
timfish opened this issue May 10, 2024 · 1 comment · Fixed by #52939
Closed
Labels
cli Issues and PRs related to the Node.js command line interface. doc Issues and PRs related to the documentations.

Comments

@timfish
Copy link
Contributor

timfish commented May 10, 2024

Affected URL(s)

https://nodejs.org/api/cli.html#-r---require-module

Description of the problem

There was a previous issue for this:
#28518

But the PR to improve this does not make this clear in the right places:
#31380

When using these args, it's important to understand their impact.

My understanding is that these arguments impact:

  • The main thread (obvious!)
  • All worker threads unless you specifically pass execArgv: [] to options
  • All processes created by child_process.fork() unless you pass execArgv: [] to options
  • All processes created by the cluster module unless you pass `execArgv: [], to settings

As requested in the previous issues, this behaviour should really be documented under --require docs here:
https://nodejs.org/api/cli.html#-r---require-module

and also for the --import docs here:
https://nodejs.org/api/cli.html#--importmodule

It might also be worth linking to this warning from both of those args because this is information is key and hidden right at the bottom of the worker thread docs:
https://nodejs.org/api/worker_threads.html#launching-worker-threads-from-preload-scripts

@timfish timfish added the doc Issues and PRs related to the documentations. label May 10, 2024
@RedYetiDev RedYetiDev added the cli Issues and PRs related to the Node.js command line interface. label May 10, 2024
@RedYetiDev
Copy link
Member

Thanks for your suggestion!

I've opened a PR to fix this, and I've marked you as the Co-Author. If you would like me to change that, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Issues and PRs related to the Node.js command line interface. doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants