Skip to content

Commit 8b83b4d

Browse files
theanarkhdanielleadams
authored andcommitted
child_process: do not need to count length when maxBuffer is Infinity
PR-URL: #43822 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 373304b commit 8b83b4d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/child_process.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,11 @@ function execFile(file, args, options, callback) {
458458
child.stdout.setEncoding(encoding);
459459

460460
child.stdout.on('data', function onChildStdout(chunk) {
461+
// Do not need to count the length
462+
if (options.maxBuffer === Infinity) {
463+
ArrayPrototypePush(_stdout, chunk);
464+
return;
465+
}
461466
const encoding = child.stdout.readableEncoding;
462467
const length = encoding ?
463468
Buffer.byteLength(chunk, encoding) :
@@ -483,6 +488,11 @@ function execFile(file, args, options, callback) {
483488
child.stderr.setEncoding(encoding);
484489

485490
child.stderr.on('data', function onChildStderr(chunk) {
491+
// Do not need to count the length
492+
if (options.maxBuffer === Infinity) {
493+
ArrayPrototypePush(_stderr, chunk);
494+
return;
495+
}
486496
const encoding = child.stderr.readableEncoding;
487497
const length = encoding ?
488498
Buffer.byteLength(chunk, encoding) :
@@ -497,7 +507,7 @@ function execFile(file, args, options, callback) {
497507
ex = new ERR_CHILD_PROCESS_STDIO_MAXBUFFER('stderr');
498508
kill();
499509
} else {
500-
_stderr.push(chunk);
510+
ArrayPrototypePush(_stderr, chunk);
501511
}
502512
});
503513
}

0 commit comments

Comments
 (0)