Skip to content

child_process, errors: introduce ERR_INVALID_SIGNATURE

child_process: use ERR_INVALID_SIGNATURE

Throw ERR_INVALID_SIGNATURE in execFile() and fork() for invalid signatures, and include a message test for those errors. Also refactors test-child-process-spawn-typeerror.js and rename it to test-child-process-argument-errors.js

errors: introduce ERR_INVALID_SIGNATURE

Introduce ERR_INVALID_SIGNATURE for heavily overloaded APIs that displays the expected signature and an overview of passed arguments. In those cases, ERR_INVALID_ARG_TYPE is not helpful enough since it's the combination of arguments that is invalid, not a specific positional argument.

Before:

> child_process.execFile('ls', {}, [1,2,3])
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'args' is invalid. Received [ 1, 2, 3 ]
    at Object.exports.execFile (child_process.js:203:11)
> child_process.fork('ls', 'test')
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'arguments[1]' is invalid. Received 'test'
    at Object.exports.fork (child_process.js:68:13)

After:

> child_process.execFile('ls', {}, [1,2,3])
TypeError [ERR_INVALID_SIGNATURE]: Function was invoked with an unknown combination of arguments.
Expected child_process.execFile(file[, args][, options][, callback])
Received child_process.execFile('ls', {}, [Array])
    at Object.exports.execFile (child_process.js:204:11)
> child_process.fork('ls', 'test')
TypeError [ERR_INVALID_SIGNATURE]: Function was invoked with an unknown combination of arguments.
Expected child_process.fork(modulePath[, args][, options])
Received child_process.fork('ls', 'test')
    at Object.exports.fork (child_process.js:68:13)
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

errors, child_process

Merge request reports

Loading