Skip to content

Commit 652877e

Browse files
koh110sam-github
authored andcommitted
child_process: change the defaults maxBuffer size
PR-URL: #27179 Refs: #23027 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 69140bc commit 652877e

8 files changed

+42
-30
lines changed

doc/api/child_process.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ changes:
151151
* `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or
152152
stderr. If exceeded, the child process is terminated and any output is
153153
truncated. See caveat at [`maxBuffer` and Unicode][].
154-
**Default:** `200 * 1024`.
154+
**Default:** `1024 * 1024`.
155155
* `killSignal` {string|integer} **Default:** `'SIGTERM'`
156156
* `uid` {number} Sets the user identity of the process (see setuid(2)).
157157
* `gid` {number} Sets the group identity of the process (see setgid(2)).
@@ -250,7 +250,7 @@ changes:
250250
* `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or
251251
stderr. If exceeded, the child process is terminated and any output is
252252
truncated. See caveat at [`maxBuffer` and Unicode][].
253-
**Default:** `200 * 1024`.
253+
**Default:** `1024 * 1024`.
254254
* `killSignal` {string|integer} **Default:** `'SIGTERM'`
255255
* `uid` {number} Sets the user identity of the process (see setuid(2)).
256256
* `gid` {number} Sets the group identity of the process (see setgid(2)).
@@ -721,7 +721,7 @@ changes:
721721
process will be killed. **Default:** `'SIGTERM'`.
722722
* `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or
723723
stderr. If exceeded, the child process is terminated. See caveat at
724-
[`maxBuffer` and Unicode][]. **Default:** `200 * 1024`.
724+
[`maxBuffer` and Unicode][]. **Default:** `1024 * 1024`.
725725
* `encoding` {string} The encoding used for all stdio inputs and outputs.
726726
**Default:** `'buffer'`.
727727
* `windowsHide` {boolean} Hide the subprocess console window that would
@@ -788,7 +788,7 @@ changes:
788788
* `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or
789789
stderr. If exceeded, the child process is terminated and any output is
790790
truncated. See caveat at [`maxBuffer` and Unicode][].
791-
**Default:** `200 * 1024`.
791+
**Default:** `1024 * 1024`.
792792
* `encoding` {string} The encoding used for all stdio inputs and outputs.
793793
**Default:** `'buffer'`.
794794
* `windowsHide` {boolean} Hide the subprocess console window that would
@@ -852,7 +852,7 @@ changes:
852852
* `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or
853853
stderr. If exceeded, the child process is terminated and any output is
854854
truncated. See caveat at [`maxBuffer` and Unicode][].
855-
**Default:** `200 * 1024`.
855+
**Default:** `1024 * 1024`.
856856
* `encoding` {string} The encoding used for all stdio inputs and outputs.
857857
**Default:** `'buffer'`.
858858
* `shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses

lib/child_process.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const {
4949
ChildProcess
5050
} = child_process;
5151

52-
const MAX_BUFFER = 200 * 1024;
52+
const MAX_BUFFER = 1024 * 1024;
5353

5454
exports.ChildProcess = ChildProcess;
5555

test/parallel/test-child-process-exec-maxbuf.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ function runChecks(err, stdio, streamName, expected) {
1212

1313
// default value
1414
{
15-
const cmd = `"${process.execPath}" -e "console.log('a'.repeat(200 * 1024))"`;
15+
const cmd =
16+
`"${process.execPath}" -e "console.log('a'.repeat(1024 * 1024))"`;
1617

1718
cp.exec(cmd, common.mustCall((err) => {
1819
assert(err instanceof RangeError);
@@ -24,11 +25,11 @@ function runChecks(err, stdio, streamName, expected) {
2425
// default value
2526
{
2627
const cmd =
27-
`${process.execPath} -e "console.log('a'.repeat(200 * 1024 - 1))"`;
28+
`${process.execPath} -e "console.log('a'.repeat(1024 * 1024 - 1))"`;
2829

2930
cp.exec(cmd, common.mustCall((err, stdout, stderr) => {
3031
assert.ifError(err);
31-
assert.strictEqual(stdout.trim(), 'a'.repeat(200 * 1024 - 1));
32+
assert.strictEqual(stdout.trim(), 'a'.repeat(1024 * 1024 - 1));
3233
assert.strictEqual(stderr, '');
3334
}));
3435
}
@@ -58,24 +59,30 @@ function runChecks(err, stdio, streamName, expected) {
5859

5960
// default value
6061
{
61-
const cmd = `"${process.execPath}" -e "console.log('a'.repeat(200 * 1024))"`;
62+
const cmd =
63+
`"${process.execPath}" -e "console.log('a'.repeat(1024 * 1024))"`;
6264

6365
cp.exec(
6466
cmd,
6567
common.mustCall((err, stdout, stderr) => {
66-
runChecks(err, { stdout, stderr }, 'stdout', 'a'.repeat(200 * 1024));
68+
runChecks(
69+
err,
70+
{ stdout, stderr },
71+
'stdout',
72+
'a'.repeat(1024 * 1024)
73+
);
6774
})
6875
);
6976
}
7077

7178
// default value
7279
{
7380
const cmd =
74-
`"${process.execPath}" -e "console.log('a'.repeat(200 * 1024 - 1))"`;
81+
`"${process.execPath}" -e "console.log('a'.repeat(1024 * 1024 - 1))"`;
7582

7683
cp.exec(cmd, common.mustCall((err, stdout, stderr) => {
7784
assert.ifError(err);
78-
assert.strictEqual(stdout.trim(), 'a'.repeat(200 * 1024 - 1));
85+
assert.strictEqual(stdout.trim(), 'a'.repeat(1024 * 1024 - 1));
7986
assert.strictEqual(stderr, '');
8087
}));
8188
}

test/parallel/test-child-process-execfile-maxbuf.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function checkFactory(streamName) {
1515
{
1616
execFile(
1717
process.execPath,
18-
['-e', 'console.log("a".repeat(200 * 1024))'],
18+
['-e', 'console.log("a".repeat(1024 * 1024))'],
1919
checkFactory('stdout')
2020
);
2121
}
@@ -24,10 +24,10 @@ function checkFactory(streamName) {
2424
{
2525
execFile(
2626
process.execPath,
27-
['-e', 'console.log("a".repeat(200 * 1024 - 1))'],
27+
['-e', 'console.log("a".repeat(1024 * 1024 - 1))'],
2828
common.mustCall((err, stdout, stderr) => {
2929
assert.ifError(err);
30-
assert.strictEqual(stdout.trim(), 'a'.repeat(200 * 1024 - 1));
30+
assert.strictEqual(stdout.trim(), 'a'.repeat(1024 * 1024 - 1));
3131
assert.strictEqual(stderr, '');
3232
})
3333
);

test/parallel/test-child-process-execfilesync-maxBuffer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ const args = [
3535
assert.deepStrictEqual(ret, msgOutBuf);
3636
}
3737

38-
// Default maxBuffer size is 200 * 1024.
38+
// Default maxBuffer size is 1024 * 1024.
3939
{
4040
assert.throws(() => {
4141
execFileSync(
4242
process.execPath,
43-
['-e', "console.log('a'.repeat(200 * 1024))"]
43+
['-e', "console.log('a'.repeat(1024 * 1024))"]
4444
);
4545
}, (e) => {
4646
assert.ok(e, 'maxBuffer should error');

test/parallel/test-child-process-execfilesync-maxbuf.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ const args = [
3434
assert.deepStrictEqual(ret, msgOutBuf);
3535
}
3636

37-
// maxBuffer size is 200 * 1024 at default.
37+
// maxBuffer size is 1024 * 1024 at default.
3838
{
3939
assert.throws(
4040
() => {
4141
execFileSync(
4242
process.execPath,
43-
['-e', "console.log('a'.repeat(200 * 1024))"],
43+
['-e', "console.log('a'.repeat(1024 * 1024))"],
4444
{ encoding: 'utf-8' }
4545
);
4646
}, (e) => {

test/parallel/test-child-process-execsync-maxbuf.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,27 @@ const args = [
3838
assert.deepStrictEqual(ret, msgOutBuf);
3939
}
4040

41-
// Default maxBuffer size is 200 * 1024.
41+
// Default maxBuffer size is 1024 * 1024.
4242
{
4343
assert.throws(() => {
44-
execSync(`"${process.execPath}" -e "console.log('a'.repeat(200 * 1024))"`);
44+
execSync(
45+
`"${process.execPath}" -e "console.log('a'.repeat(1024 * 1024))"`
46+
);
4547
}, (e) => {
4648
assert.ok(e, 'maxBuffer should error');
4749
assert.strictEqual(e.errno, 'ENOBUFS');
4850
return true;
4951
});
5052
}
5153

52-
// Default maxBuffer size is 200 * 1024.
54+
// Default maxBuffer size is 1024 * 1024.
5355
{
5456
const ret = execSync(
55-
`"${process.execPath}" -e "console.log('a'.repeat(200 * 1024 - 1))"`
57+
`"${process.execPath}" -e "console.log('a'.repeat(1024 * 1024 - 1))"`
5658
);
5759

58-
assert.deepStrictEqual(ret.toString().trim(), 'a'.repeat(200 * 1024 - 1));
60+
assert.deepStrictEqual(
61+
ret.toString().trim(),
62+
'a'.repeat(1024 * 1024 - 1)
63+
);
5964
}

test/parallel/test-child-process-spawnsync-maxbuf.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ const args = [
3333
assert.deepStrictEqual(ret.stdout, msgOutBuf);
3434
}
3535

36-
// Default maxBuffer size is 200 * 1024.
36+
// Default maxBuffer size is 1024 * 1024.
3737
{
38-
const args = ['-e', "console.log('a'.repeat(200 * 1024))"];
38+
const args = ['-e', "console.log('a'.repeat(1024 * 1024))"];
3939
const ret = spawnSync(process.execPath, args);
4040

4141
assert.ok(ret.error, 'maxBuffer should error');
4242
assert.strictEqual(ret.error.errno, 'ENOBUFS');
4343
}
4444

45-
// Default maxBuffer size is 200 * 1024.
45+
// Default maxBuffer size is 1024 * 1024.
4646
{
47-
const args = ['-e', "console.log('a'.repeat(200 * 1024 - 1))"];
47+
const args = ['-e', "console.log('a'.repeat(1024 * 1024 - 1))"];
4848
const ret = spawnSync(process.execPath, args);
4949

5050
assert.ifError(ret.error);
5151
assert.deepStrictEqual(
5252
ret.stdout.toString().trim(),
53-
'a'.repeat(200 * 1024 - 1)
53+
'a'.repeat(1024 * 1024 - 1)
5454
);
5555
}

0 commit comments

Comments
 (0)