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

Forked cluster does not fix up process.execArgv after filename when executed by module.runMain() #36948

Open
JLHwung opened this issue Jan 15, 2021 · 1 comment
Labels
cluster Issues and PRs related to the cluster subsystem.

Comments

@JLHwung
Copy link

JLHwung commented Jan 15, 2021

  • Version: v15.5.1
  • Platform: Darwin jh.local 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64
  • Subsystem: cluster, module

What steps will reproduce the bug?

node --expose_gc ./wrapper.js ./payload.js

See https://gist.github.com/JLHwung/631dfbf4a4c68d85ae7a9b7ab5fa9754 for ./wrapper.js and ./payload.js.

How often does it reproduce? Is there a required condition?

What is the expected behavior?

It should print

[Function: gc] true
[Function: gc]

What do you see instead?

[Function: gc] true
undefined

Additional information

Context: babel/babel#12635

process.execArgv is

["/path/to/babel-node.js", "--expose_gc"]

It seems that forked clusters stop fixing up execArgv after "/path/to/babel-node.js" is read. If I place "/path/to/babel-node.js" after "--expose_gc", it works as expected.

As module.runMain is undocumented. The actual behaviour may be limbo. However as it is used by both Babel and npx, would you consider document it or deprecate it via better approach? 😄

@JLHwung
Copy link
Author

JLHwung commented Jan 15, 2021

Closing this as the executed filename should come after Nodejs specific command-line options.

@JLHwung JLHwung closed this as completed Jan 15, 2021
@JLHwung JLHwung reopened this Jan 15, 2021
@JLHwung JLHwung changed the title Forked cluster does not fix up process.execArgv when executed by module.runMain() Forked cluster does not fix up process.execArgv after filename when executed by module.runMain() Jan 15, 2021
JLHwung added a commit to JLHwung/babel that referenced this issue Jan 15, 2021
JLHwung added a commit to babel/babel that referenced this issue Jan 18, 2021
@PoojaDurgad PoojaDurgad added the cluster Issues and PRs related to the cluster subsystem. label Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cluster Issues and PRs related to the cluster subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants