-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Closed
Labels
child_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.
Description
- Version: v9.3.0
- Platform: Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jan 11 22:59:40 PST 2018; root:xnu-3789.73.8~1/RELEASE_X86_64 x86_64
- Subsystem:
Execute code at node command line.
const cp = require('child_process');
const child = cp.exec('pwd', {encoding: 'invalid'}, (err, stdout, stderr) => {
console.log('callback', err)
console.log('callback', typeof stdout, stdout)
})
child.stdout.setEncoding('utf8')
child.stdout.on('data', function (v) {
console.log(typeof v, v)
})
The output is :
buffer.js:475
throw new errors.TypeError(
^
TypeError [ERR_INVALID_ARG_TYPE]: The "list" argument must be one of type Array, Buffer, or Uint8Array
at Function.concat (buffer.js:475:13)
at ChildProcess.exithandler (child_process.js:259:23)
at ChildProcess.emit (events.js:159:13)
at maybeClose (internal/child_process.js:943:16)
at Socket.stream.socket.on (internal/child_process.js:363:11)
at Socket.emit (events.js:159:13)
at Pipe._handle.close [as _onclose] (net.js:568:12)
Is this a bug in nodejs?
BTW: The issue finder is @xqin
There didn't trigger the exception if use cp.exec('pwd', {encoding: 'invalid'})
without the callback.
@xqin has a new idea that whether need bind listener on stdout
and stderr
when user not pass the callback param. The source code at: https://github.com/nodejs/node/blob/master/lib/child_process.js#L322-L358
Metadata
Metadata
Assignees
Labels
child_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.