From a470f2ca00ee67c030cc97c4c9c1196f7782146e Mon Sep 17 00:00:00 2001 From: theanarkh Date: Wed, 13 Jul 2022 22:58:09 +0800 Subject: [PATCH] child_process: skip count length when maxBuffer is Infinity --- lib/child_process.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/child_process.js b/lib/child_process.js index 605bd14660f5212..1ac64f355828c74 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -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) : @@ -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) :