Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

child_process: skip count length when maxBuffer is Infinity #43822

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion 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) {
// Do not need to count the length
if (options.maxBuffer === Infinity) {
theanarkh marked this conversation as resolved.
Show resolved Hide resolved
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) {
// Do not need to count the length
if (options.maxBuffer === Infinity) {
ArrayPrototypePush(_stderr, chunk);
return;
}
const encoding = child.stderr.readableEncoding;
const length = encoding ?
Buffer.byteLength(chunk, encoding) :
Expand All @@ -476,7 +486,7 @@ function execFile(file, args = [], options, callback) {
ex = new ERR_CHILD_PROCESS_STDIO_MAXBUFFER('stderr');
kill();
} else {
_stderr.push(chunk);
ArrayPrototypePush(_stderr, chunk);
}
});
}
Expand Down