-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
child_process: preserve argument type
A previous fix for a `maxBuffer` bug resulted in a change to the argument type for the `data` event on `child.stdin` and `child.stdout` when using `child_process.exec()`. This fixes the `maxBuffer` bug in a way that does not have that side effect. PR-URL: #7391 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jackson Tian <shyvo1987@gmail.com> Fixes: #7342 Refs: #1901
- Loading branch information
1 parent
4a0fb6f
commit 2aa06b9
Showing
5 changed files
with
56 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const cp = require('child_process'); | ||
|
||
function checkFactory(streamName) { | ||
return common.mustCall((err) => { | ||
const message = `${streamName} maxBuffer exceeded`; | ||
assert.strictEqual(err.message, message); | ||
}); | ||
} | ||
|
||
{ | ||
const cmd = 'echo "hello world"'; | ||
|
||
cp.exec(cmd, { maxBuffer: 5 }, checkFactory('stdout')); | ||
} | ||
|
||
const unicode = '中文测试'; // length = 4, byte length = 12 | ||
|
||
{ | ||
const cmd = `"${process.execPath}" -e "console.log('${unicode}');"`; | ||
|
||
cp.exec(cmd, {maxBuffer: 10}, checkFactory('stdout')); | ||
} | ||
|
||
{ | ||
const cmd = `"${process.execPath}" -e "console.('${unicode}');"`; | ||
|
||
cp.exec(cmd, {maxBuffer: 10}, checkFactory('stderr')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.