Skip to content

Commit 231f56b

Browse files
theanarkhtargos
authored andcommitted
child_process: do not need to count length when maxBuffer is Infinity
PR-URL: #43822 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
1 parent 70f7680 commit 231f56b

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
@@ -448,6 +448,11 @@ function execFile(file, args = [], options, callback) {
448448
child.stdout.setEncoding(encoding);
449449

450450
child.stdout.on('data', function onChildStdout(chunk) {
451+
// Do not need to count the length
452+
if (options.maxBuffer === Infinity) {
453+
ArrayPrototypePush(_stdout, chunk);
454+
return;
455+
}
451456
const encoding = child.stdout.readableEncoding;
452457
const length = encoding ?
453458
Buffer.byteLength(chunk, encoding) :
@@ -473,6 +478,11 @@ function execFile(file, args = [], options, callback) {
473478
child.stderr.setEncoding(encoding);
474479

475480
child.stderr.on('data', function onChildStderr(chunk) {
481+
// Do not need to count the length
482+
if (options.maxBuffer === Infinity) {
483+
ArrayPrototypePush(_stderr, chunk);
484+
return;
485+
}
476486
const encoding = child.stderr.readableEncoding;
477487
const length = encoding ?
478488
Buffer.byteLength(chunk, encoding) :
@@ -487,7 +497,7 @@ function execFile(file, args = [], options, callback) {
487497
ex = new ERR_CHILD_PROCESS_STDIO_MAXBUFFER('stderr');
488498
kill();
489499
} else {
490-
_stderr.push(chunk);
500+
ArrayPrototypePush(_stderr, chunk);
491501
}
492502
});
493503
}

0 commit comments

Comments
 (0)