mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
child_process: do not need to count length when maxBuffer is Infinity
PR-URL: https://github.com/nodejs/node/pull/43822 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
1 parent
2e71ac680c
commit
04840223ee
1 file changed
+11
-1
+11
-1
@@ -458,6 +458,11 @@ function execFile(file, args, options, callback) {
|
||||
child.stdout.setEncoding(encoding);
|
||||
|
||||
child.stdout.on('data', function onChildStdout(chunk) {
|
||||
// Do not need to count the length
|
||||
if (options.maxBuffer === Infinity) {
|
||||
ArrayPrototypePush(_stdout, chunk);
|
||||
return;
|
||||
}
|
||||
const encoding = child.stdout.readableEncoding;
|
||||
const length = encoding ?
|
||||
Buffer.byteLength(chunk, encoding) :
|
||||
@@ -483,6 +488,11 @@ function execFile(file, args, options, callback) {
|
||||
child.stderr.setEncoding(encoding);
|
||||
|
||||
child.stderr.on('data', function onChildStderr(chunk) {
|
||||
// Do not need to count the length
|
||||
if (options.maxBuffer === Infinity) {
|
||||
ArrayPrototypePush(_stderr, chunk);
|
||||
return;
|
||||
}
|
||||
const encoding = child.stderr.readableEncoding;
|
||||
const length = encoding ?
|
||||
Buffer.byteLength(chunk, encoding) :
|
||||
@@ -497,7 +507,7 @@ function execFile(file, args, options, callback) {
|
||||
ex = new ERR_CHILD_PROCESS_STDIO_MAXBUFFER('stderr');
|
||||
kill();
|
||||
} else {
|
||||
_stderr.push(chunk);
|
||||
ArrayPrototypePush(_stderr, chunk);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user