@@ -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