Skip to content

Commit 7e748c0

Browse files
committed
child_process: do not need to count length when maxBuffer is Infinity
1 parent ba67fe6 commit 7e748c0

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

439439
child.stdout.on('data', function onChildStdout(chunk) {
440+
// Do not need to count the length
441+
if (options.maxBuffer === Infinity) {
442+
ArrayPrototypePush(_stdout, chunk);
443+
return;
444+
}
440445
const encoding = child.stdout.readableEncoding;
441446
const length = encoding ?
442447
Buffer.byteLength(chunk, encoding) :
@@ -462,6 +467,11 @@ function execFile(file, args = [], options, callback) {
462467
child.stderr.setEncoding(encoding);
463468

464469
child.stderr.on('data', function onChildStderr(chunk) {
470+
// Do not need to count the length
471+
if (options.maxBuffer === Infinity) {
472+
ArrayPrototypePush(_stderr, chunk);
473+
return;
474+
}
465475
const encoding = child.stderr.readableEncoding;
466476
const length = encoding ?
467477
Buffer.byteLength(chunk, encoding) :
@@ -476,7 +486,7 @@ function execFile(file, args = [], options, callback) {
476486
ex = new ERR_CHILD_PROCESS_STDIO_MAXBUFFER('stderr');
477487
kill();
478488
} else {
479-
_stderr.push(chunk);
489+
ArrayPrototypePush(_stderr, chunk);
480490
}
481491
});
482492
}

0 commit comments

Comments
 (0)