child_process: harden fork arguments validation
Ensure that the first argument modulePath
of fork
method must be provided and be of type string.
Also merge test-child-process-fork-options.js
(which ensure that the second argument can be undefined
or null
) into test-child-process-fork-args.js
Maybe should be semver-major
since different error now ?
Before:
> child_process.fork()
...
> internal/modules/cjs/loader.js:651
throw err;
^
Error: Cannot find module '/Users/zyszys/Projects/nodejs/node/undefined'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:649:15)
at Function.Module._load (internal/modules/cjs/loader.js:575:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:862:12)
at internal/main/run_main_module.js:21:11
After validation:
> child_process.fork()
Thrown:
TypeError [ERR_INVALID_ARG_TYPE]: The "modulePath" argument must be of type string. Received type undefined
at validateString (internal/validators.js:105:11)
at Object.fork (child_process.js:63:3)
at repl:1:15
at Script.runInThisContext (vm.js:124:20)
at REPLServer.defaultEval (repl.js:360:29)
at bound (domain.js:413:14)
at REPLServer.runBound [as eval] (domain.js:426:12)
at REPLServer.onLine (repl.js:667:10)
at REPLServer.emit (events.js:199:15)
at REPLServer.EventEmitter.emit (domain.js:469:20)
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines