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

worker: process.argv for workers #30531

Closed
legendecas opened this issue Nov 18, 2019 · 3 comments
Closed

worker: process.argv for workers #30531

legendecas opened this issue Nov 18, 2019 · 3 comments
Labels
feature request Issues that request new features to be added to Node.js. worker Issues and PRs related to Worker support.

Comments

@legendecas
Copy link
Member

Is your feature request related to a problem? Please describe.
process.argv is commonly used in Node.js. Right now there is only execArgv for altering how node instance works, which will be filtered process.argv with these only Node.js understands.

Describe the solution you'd like
Add an option argv to Worker constructor's second argument.

new Worker(__filename, { argv: ['foo', 'bar'] })
if (!isMainThread) {
  console.log(process.argv) // ['foo', 'bar']
}

Describe alternatives you've considered
Just use option workerData in Worker constructor's second argument.

@legendecas legendecas added the worker Issues and PRs related to Worker support. label Nov 18, 2019
@addaleax addaleax added the feature request Issues that request new features to be added to Node.js. label Nov 18, 2019
@addaleax
Copy link
Member

@legendecas Feel free to open a PR with this if you like – I think you can pass it around the same way that we pass workerData.

I would suggest process.argv to follow the standard format though, i.e. process.argv[0] is the Node.js binary being used and process.argv[1] is the main script name (of the Worker thread, in this case).

@legendecas
Copy link
Member Author

@addaleax 😄 I'd like to. Just open the issue to ask around if it was left there intentionally.

@addaleax
Copy link
Member

@legendecas As far as I am concerned, workerData was intended to be the (far more powerful) alternative that we’d use for worker threads, but I don’t personally see any issue with adding a more main-thread-like process.argv.

targos pushed a commit that referenced this issue Dec 9, 2019
A convenience option to populate `process.argv` in worker threads.

PR-URL: #30559
Fixes: #30531
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
targos pushed a commit that referenced this issue Jan 14, 2020
A convenience option to populate `process.argv` in worker threads.

PR-URL: #30559
Fixes: #30531
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
BethGriggs pushed a commit that referenced this issue Feb 6, 2020
A convenience option to populate `process.argv` in worker threads.

PR-URL: #30559
Fixes: #30531
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
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
None yet
Development

Successfully merging a pull request may close this issue.

2 participants