@@ -437,6 +437,11 @@ function execFile(file, args = [], options, callback) {
437
437
child . stdout . setEncoding ( encoding ) ;
438
438
439
439
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
+ }
440
445
const encoding = child . stdout . readableEncoding ;
441
446
const length = encoding ?
442
447
Buffer . byteLength ( chunk , encoding ) :
@@ -462,6 +467,11 @@ function execFile(file, args = [], options, callback) {
462
467
child . stderr . setEncoding ( encoding ) ;
463
468
464
469
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
+ }
465
475
const encoding = child . stderr . readableEncoding ;
466
476
const length = encoding ?
467
477
Buffer . byteLength ( chunk , encoding ) :
@@ -476,7 +486,7 @@ function execFile(file, args = [], options, callback) {
476
486
ex = new ERR_CHILD_PROCESS_STDIO_MAXBUFFER ( 'stderr' ) ;
477
487
kill ( ) ;
478
488
} else {
479
- _stderr . push ( chunk ) ;
489
+ ArrayPrototypePush ( _stderr , chunk ) ;
480
490
}
481
491
} ) ;
482
492
}
0 commit comments