diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 68b4b447f68ad7..44d19966768587 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -22,7 +22,11 @@ const { ERR_MISSING_ARGS } } = require('internal/errors'); -const { validateString, validateOneOf } = require('internal/validators'); +const { + validateArray, + validateOneOf, + validateString, +} = require('internal/validators'); const EventEmitter = require('events'); const net = require('net'); const dgram = require('dgram'); @@ -356,11 +360,8 @@ ChildProcess.prototype.spawn = function(options) { // Let child process know about opened IPC channel if (options.envPairs === undefined) options.envPairs = []; - else if (!ArrayIsArray(options.envPairs)) { - throw new ERR_INVALID_ARG_TYPE('options.envPairs', - 'Array', - options.envPairs); - } + else + validateArray(options.envPairs, 'options.envPairs'); options.envPairs.push(`NODE_CHANNEL_FD=${ipcFd}`); options.envPairs.push(`NODE_CHANNEL_SERIALIZATION_MODE=${serialization}`);