Skip to content

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

@jsinterface

Description

@jsinterface

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    clusterIssues and PRs related to the cluster subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions