Skip to content

Commit

Permalink
child_process: skip count length when maxBuffer is Infinity
Browse files Browse the repository at this point in the history
  • Loading branch information
theanarkh committed Jul 13, 2022
1 parent ba67fe6 commit a470f2c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ function execFile(file, args = [], options, callback) {
child.stdout.setEncoding(encoding);

child.stdout.on('data', function onChildStdout(chunk) {
// Skip count the length
if (options.maxBuffer === Infinity) {
ArrayPrototypePush(_stdout, chunk);
return;
}
const encoding = child.stdout.readableEncoding;
const length = encoding ?
Buffer.byteLength(chunk, encoding) :
Expand All @@ -462,6 +467,11 @@ function execFile(file, args = [], options, callback) {
child.stderr.setEncoding(encoding);

child.stderr.on('data', function onChildStderr(chunk) {
// Skip count the length
if (options.maxBuffer === Infinity) {
_stderr.push(chunk);
return;
}
const encoding = child.stderr.readableEncoding;
const length = encoding ?
Buffer.byteLength(chunk, encoding) :
Expand Down

0 comments on commit a470f2c

Please sign in to comment.