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

cluster.fork() fails when called in repl (cluster.settings.exec undefined) #35158

Open
bpstrngr opened this issue Sep 11, 2020 · 1 comment
Open
Labels
cluster Issues and PRs related to the cluster subsystem.

Comments

@bpstrngr
Copy link

bpstrngr commented Sep 11, 2020

Running v14.4, I launched my script with cli dynamic import:
node -e 'import("./seed.js").then(({open})=>open());'
and I get the following error on fork process creation:

TypeError [ERR_INVALID_ARG_TYPE]: The "modulePath" argument must be of type string. Received undefined
    at validateString (internal/validators.js:121:11)
    at fork (child_process.js:63:3)
    at createWorkerProcess (internal/cluster/master.js:132:10)
    at EventEmitter.cluster.fork (internal/cluster/master.js:167:25)
    at file:///media/fuse/drivefs-fb63ac1d072197a08fd8e42d246fd29a/root/www.blikpatrik.net/Blik_2020_seed.js:40:58
    at Array.map (<anonymous>)
    at file:///media/fuse/drivefs-fb63ac1d072197a08fd8e42d246fd29a/root/www.blikpatrik.net/Blik_2020_seed.js:40:41

in internal/cluster/master.js:132,
createWorkerProcess(id,env) function passes cluster.settings.exec down empty to fork(modulePath)
after cluster.setupMaster() has it set from process.argv[1]
(which is empty due to --eval usage)
at internal/cluster/master.js:57.

I see running code dynamically as an equally reasonable use case
for forking processes so i suppose this is not intended.

I wonder if import.meta.url could be utilised for a solution, at least as an optional argument.

Thanks for the attention!

only related issue i found:
#27039

@bpstrngr bpstrngr changed the title cluster.settings.exec undefined as cluster.fork() argument when called in repl cluster.fork() fails when called in repl (cluster.settings.exec undefined) Oct 2, 2020
@bpstrngr
Copy link
Author

bpstrngr commented Oct 2, 2020

The solution for me in the meantime has been to set a mock entry point before forking,
which a bit surprisingly doesn't influence the childprocesses
launching with the correct initial command so it works fine.
if(!process.argv[1])
process.argv[1]=import.meta.url;

@PoojaDurgad PoojaDurgad added the cluster Issues and PRs related to the cluster subsystem. label Oct 22, 2020
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