Improve `maxBuffer` option with `execaSync()` (#960)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent bdda475 · Browse files · 8 files·+171 added−71 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+171 added−71 removed
- tests:+115 added−50 removed
- other:+56 added−21 removed
Provenance
- Commit
dce0393- Tree
d34488c- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
bdda475
8 files changed+171 added−71 removed
modified:lib/exit/code.js+9 added-6 removed
8 unmodified lines910111213141516171314151617181920211922232425265 unmodified lines8 unmodified lines
return [exitCode, signal];};
export const getSyncExitResult = ({error, status: exitCode, signal}) => ({ resultError: getSyncError(error, exitCode, signal), exitCode, signal,});export const getSyncExitResult = ({error, status: exitCode, signal, output}, {maxBuffer}) => { const resultError = getResultError(error, exitCode, signal); const timedOut = resultError?.code === 'ETIMEDOUT'; const isMaxBuffer = resultError?.code === 'ENOBUFS' && output !== null && output.some(result => result !== null && result.length > maxBuffer); return {resultError, exitCode, signal, timedOut, isMaxBuffer};};
const getSyncError = (error, exitCode, signal) => {const getResultError = (error, exitCode, signal) => { if (error !== undefined) { return error; }
5 unmodified linesmodified:lib/stdio/output-sync.js+9 added-4 removed
3 unmodified lines45678891011121314151516171819192021222324252625272829309 unmodified lines40414243444546474849505158 unmodified lines3 unmodified linesimport {splitLinesSync} from './split.js';import {FILE_TYPES} from './type.js';
// Apply `stdout`/`stderr` options, after spawning, in sync modeexport const transformOutputSync = (fileDescriptors, {output}, options) => {export const transformOutputSync = ({fileDescriptors, syncResult: {output}, options, isMaxBuffer}) => { if (output === null) { return {output: Array.from({length: 3})}; }
const state = {}; const transformedOutput = output.map((result, fdNumber) => transformOutputResultSync({result, fileDescriptors, fdNumber, state}, options)); transformOutputResultSync({result, fileDescriptors, fdNumber, state, isMaxBuffer}, options)); return {output: transformedOutput, ...state};};
const transformOutputResultSync = ({result, fileDescriptors, fdNumber, state}, {buffer, encoding, lines, stripFinalNewline}) => {const transformOutputResultSync = ({result, fileDescriptors, fdNumber, state, isMaxBuffer}, {buffer, encoding, lines, stripFinalNewline, maxBuffer}) => { if (result === null) { return; }
const truncatedResult = truncateResult(result, isMaxBuffer, maxBuffer); const uint8ArrayResult = bufferToUint8Array(truncatedResult); const {stdioItems, objectMode} = fileDescriptors[fdNumber]; const uint8ArrayResult = bufferToUint8Array(result); const generators = getGenerators(stdioItems); const chunks = runOutputGeneratorsSync([uint8ArrayResult], generators, encoding, state); const {serializedResult, finalResult} = serializeChunks({chunks, objectMode, encoding, lines, stripFinalNewline}); const returnedResult = buffer ? finalResult : undefined;9 unmodified lines return returnedResult; }};
const truncateResult = (result, isMaxBuffer, maxBuffer) => isMaxBuffer && result.length > maxBuffer ? result.slice(0, maxBuffer) : result;
const runOutputGeneratorsSync = (chunks, generators, encoding, state) => { try { return runGeneratorsSync(chunks, generators, encoding); } catch (error) {58 unmodified linesmodified:lib/sync.js+5 added-5 removed
53 unmodified lines54 if (syncResult.failed) {55 return syncResult;56 }57 58- const {resultError, exitCode, signal} = getSyncExitResult(syncResult);59- const {output, error = resultError} = transformOutputSync(fileDescriptors, syncResult, options);58+ const {resultError, exitCode, signal, timedOut, isMaxBuffer} = getSyncExitResult(syncResult, options);59+ const {output, error = resultError} = transformOutputSync({fileDescriptors, syncResult, options, isMaxBuffer});60 const stdio = output.map(stdioOutput => stripNewline(stdioOutput, options));61 const all = stripNewline(getAllSync(output, options), options);62- return getSyncResult({error, exitCode, signal, stdio, all, options, command, escapedCommand, startTime});62+ return getSyncResult({error, exitCode, signal, timedOut, stdio, all, options, command, escapedCommand, startTime});63 };64 65 const runSubprocessSync = ({file, args, options, command, escapedCommand, fileDescriptors, startTime}) => {66 try {6 unmodified lines73 };74 75 const normalizeSpawnSyncOptions = ({encoding, ...options}) => ({...options, encoding: 'buffer'});76 77-const getSyncResult = ({error, exitCode, signal, stdio, all, options, command, escapedCommand, startTime}) => error === undefined77+const getSyncResult = ({error, exitCode, signal, timedOut, stdio, all, options, command, escapedCommand, startTime}) => error === undefined78 ? makeSuccessResult({command, escapedCommand, stdio, all, options, startTime})79 : makeError({80 error,81 command,82 escapedCommand,83- timedOut: error.code === 'ETIMEDOUT',83+ timedOut,84 isCanceled: false,85 exitCode,86 signal,87 stdio,5 unmodified linesmodified:test/stdio/lines.js+12 added
135 unmodified lines136 t.true(cause instanceof MaxBufferError);137 t.deepEqual(stdout, noNewlinesChunks.slice(0, maxBuffer));138 });139 140+test('"maxBuffer" is measured in lines with "lines: true"', async t => {141+ const {stdout} = await t.throwsAsync(execa('noop-repeat.js', ['1', '...\n'], {lines: true, maxBuffer: 2}));142+ t.deepEqual(stdout, ['...', '...']);143+});144+145+test('"maxBuffer" is measured in bytes with "lines: true", sync', t => {146+ const {stdout} = t.throws(() => {147+ execaSync('noop-repeat.js', ['1', '...\n'], {lines: true, maxBuffer: 2});148+ }, {code: 'ENOBUFS'});149+ t.deepEqual(stdout, ['..']);150+});151+152 test('"lines: true" stops on stream error', async t => {153 const cause = new Error(foobarString);154 const error = await t.throwsAsync(getSimpleChunkSubprocessAsync({155 * stdout(line) {67 unmodified linesmodified:test/stdio/transform.js+27 added-3 removed
151 unmodified lines152 stdout: generatorsMap[type].getOutput(bigString)(false, true),153 });154 t.is(stdout, bigString);155 156- await t.throwsAsync(execa('noop.js', {maxBuffer, stdout: generatorsMap[type].getOutput(`${bigString}.`)(false)}));156+ await t.throwsAsync(execa('noop.js', {157+ maxBuffer,158+ stdout: generatorsMap[type].getOutput(`${bigString}.`)(false, true),159+ }));160 };161 162 test('Generators take "maxBuffer" into account', testMaxBuffer, 'generator');163 test('Duplexes take "maxBuffer" into account', testMaxBuffer, 'duplex');164 test('WebTransforms take "maxBuffer" into account', testMaxBuffer, 'webTransform');165 166+test('Generators does not take "maxBuffer" into account, sync', t => {167+ const bigString = '.'.repeat(maxBuffer);168+ const {stdout} = execaSync('noop.js', {169+ maxBuffer,170+ stdout: generatorsMap.generator.getOutput(`${bigString}.`)(false, true),171+ });172+ t.is(stdout.length, maxBuffer + 1);173+});174+175 const testMaxBufferObject = async (t, type) => {164- const bigArray = Array.from({length: maxBuffer}).fill('.');176+ const bigArray = Array.from({length: maxBuffer}).fill('..');177 const {stdout} = await execa('noop.js', {178 maxBuffer,179 stdout: generatorsMap[type].getOutputs(bigArray)(true, true),180 });181 t.is(stdout.length, maxBuffer);182 171- await t.throwsAsync(execa('noop.js', {maxBuffer, stdout: generatorsMap[type].getOutputs([...bigArray, ''])(true)}));183+ await t.throwsAsync(execa('noop.js', {184+ maxBuffer,185+ stdout: generatorsMap[type].getOutputs([...bigArray, ''])(true, true),186+ }));187 };188 189 test('Generators take "maxBuffer" into account, objectMode', testMaxBufferObject, 'generator');190 test('Duplexes take "maxBuffer" into account, objectMode', testMaxBufferObject, 'duplex');191 test('WebTransforms take "maxBuffer" into account, objectMode', testMaxBufferObject, 'webTransform');192 193+test('Generators does not take "maxBuffer" into account, objectMode, sync', t => {194+ const bigArray = Array.from({length: maxBuffer}).fill('..');195+ const {stdout} = execaSync('noop.js', {196+ maxBuffer,197+ stdout: generatorsMap.generator.getOutputs([...bigArray, ''])(true, true),198+ });199+ t.is(stdout.length, maxBuffer + 1);200+});201+202 const testAsyncGenerators = async (t, type, final) => {203 const {stdout} = await execa('noop.js', {204 stdout: convertTransformToFinal(generatorsMap[type].timeout(1e2)(), final),205 });87 unmodified linesmodified:test/stream/max-buffer.js+76 added-47 removed
8 unmodified lines9 10 const maxBuffer = 10;11 const maxBufferMessage = /maxBuffer exceeded/;12 13+const runMaxBuffer = (t, execaMethod, fdNumber, options) => execaMethod === execa14+ ? t.throwsAsync(getMaxBufferSubprocess(execaMethod, fdNumber, options), {message: maxBufferMessage})15+ : t.throws(() => {16+ getMaxBufferSubprocess(execaMethod, fdNumber, options);17+ }, {code: 'ENOBUFS'});18+19+const getMaxBufferSubprocess = (execaMethod, fdNumber, {length = maxBuffer, ...options} = {}) =>20+ execaMethod('max-buffer.js', [`${fdNumber}`, `${length + 1}`], {...fullStdio, maxBuffer, ...options});21+22+const getExpectedOutput = (length = maxBuffer) => '.'.repeat(length);23+24 const testMaxBufferSuccess = async (t, fdNumber, all) => {14- await t.notThrowsAsync(execa('max-buffer.js', [`${fdNumber}`, `${maxBuffer}`], {...fullStdio, maxBuffer, all}));25+ await t.notThrowsAsync(getMaxBufferSubprocess(execa, fdNumber, {all, length: maxBuffer - 1}));26 };27 28 test('maxBuffer does not affect stdout if too high', testMaxBufferSuccess, 1, false);29 test('maxBuffer does not affect stderr if too high', testMaxBufferSuccess, 2, false);30 test('maxBuffer does not affect stdio[*] if too high', testMaxBufferSuccess, 3, false);31 test('maxBuffer does not affect all if too high', testMaxBufferSuccess, 1, true);32 33+const testMaxBufferSuccessSync = (t, fdNumber, all) => {34+ t.notThrows(() => {35+ getMaxBufferSubprocess(execaSync, fdNumber, {all, length: maxBuffer - 1});36+ });37+};38+39+test('maxBuffer does not affect stdout if too high, sync', testMaxBufferSuccessSync, 1, false);40+test('maxBuffer does not affect stderr if too high, sync', testMaxBufferSuccessSync, 2, false);41+test('maxBuffer does not affect stdio[*] if too high, sync', testMaxBufferSuccessSync, 3, false);42+test('maxBuffer does not affect all if too high, sync', testMaxBufferSuccessSync, 1, true);43+44 const testGracefulExit = async (t, fixtureName, expectedExitCode) => {45 const {exitCode, signal, stdout} = await t.throwsAsync(46 execa(fixtureName, ['1', '.'.repeat(maxBuffer + 1)], {maxBuffer}),47 {message: maxBufferMessage},48 );49 t.is(exitCode, expectedExitCode);50 t.is(signal, undefined);29- t.is(stdout, '.'.repeat(maxBuffer));51+ t.is(stdout, getExpectedOutput());52 };53 54 test('maxBuffer terminates stream gracefully, more writes', testGracefulExit, 'noop-repeat.js', 1);55 test('maxBuffer terminates stream gracefully, no more writes', testGracefulExit, 'noop-fd.js', 0);56 35-const testMaxBufferLimit = async (t, fdNumber, all) => {36- const length = all ? maxBuffer * 2 : maxBuffer;37- const result = await t.throwsAsync(38- execa('max-buffer.js', [`${fdNumber}`, `${length + 1}`], {...fullStdio, maxBuffer, all}),39- {message: maxBufferMessage},40- );41- t.is(all ? result.all : result.stdio[fdNumber], '.'.repeat(length));57+const testGracefulExitSync = (t, fixtureName) => {58+ const {exitCode, signal, stdout} = t.throws(() => {59+ execaSync(fixtureName, ['1', '.'.repeat(maxBuffer + 1)], {maxBuffer, killSignal: 'SIGINT'});60+ }, {code: 'ENOBUFS'});61+ t.is(exitCode, undefined);62+ t.is(signal, 'SIGINT');63+ t.is(stdout, getExpectedOutput());64 };65 44-test('maxBuffer affects stdout', testMaxBufferLimit, 1, false);45-test('maxBuffer affects stderr', testMaxBufferLimit, 2, false);46-test('maxBuffer affects stdio[*]', testMaxBufferLimit, 3, false);47-test('maxBuffer affects all', testMaxBufferLimit, 1, true);66+test('maxBuffer terminate stream with killSignal, more writes, sync', testGracefulExitSync, 'noop-repeat.js');67+test('maxBuffer terminate stream with killSignal, no more writes, sync', testGracefulExitSync, 'noop-fd.js');68 49-const testMaxBufferEncoding = async (t, fdNumber) => {50- const result = await t.throwsAsync(51- execa('max-buffer.js', [`${fdNumber}`, `${maxBuffer + 1}`], {...fullStdio, maxBuffer, encoding: 'buffer'}),52- );69+const testMaxBufferLimit = async (t, execaMethod, fdNumber, all) => {70+ const length = all && execaMethod === execa ? maxBuffer * 2 : maxBuffer;71+ const result = await runMaxBuffer(t, execaMethod, fdNumber, {all, length});72+ t.is(all ? result.all : result.stdio[fdNumber], getExpectedOutput(length));73+};74+75+test('maxBuffer truncates stdout', testMaxBufferLimit, execa, 1, false);76+test('maxBuffer truncates stderr', testMaxBufferLimit, execa, 2, false);77+test('maxBuffer truncates stdio[*]', testMaxBufferLimit, execa, 3, false);78+test('maxBuffer truncates all', testMaxBufferLimit, execa, 1, true);79+test('maxBuffer truncates stdout, sync', testMaxBufferLimit, execaSync, 1, false);80+test('maxBuffer truncates stderr, sync', testMaxBufferLimit, execaSync, 2, false);81+test('maxBuffer truncates stdio[*], sync', testMaxBufferLimit, execaSync, 3, false);82+test('maxBuffer truncates all, sync', testMaxBufferLimit, execaSync, 1, true);83+84+const testMaxBufferEncoding = async (t, execaMethod, fdNumber) => {85+ const result = await runMaxBuffer(t, execaMethod, fdNumber, {encoding: 'buffer'});86 const stream = result.stdio[fdNumber];87 t.true(stream instanceof Uint8Array);55- t.is(Buffer.from(stream).toString(), '.'.repeat(maxBuffer));88+ t.is(Buffer.from(stream).toString(), getExpectedOutput());89 };90 58-test('maxBuffer works with encoding buffer and stdout', testMaxBufferEncoding, 1);59-test('maxBuffer works with encoding buffer and stderr', testMaxBufferEncoding, 2);60-test('maxBuffer works with encoding buffer and stdio[*]', testMaxBufferEncoding, 3);91+test('maxBuffer works with encoding buffer and stdout', testMaxBufferEncoding, execa, 1);92+test('maxBuffer works with encoding buffer and stderr', testMaxBufferEncoding, execa, 2);93+test('maxBuffer works with encoding buffer and stdio[*]', testMaxBufferEncoding, execa, 3);94+test('maxBuffer works with encoding buffer and stdout, sync', testMaxBufferEncoding, execaSync, 1);95+test('maxBuffer works with encoding buffer and stderr, sync', testMaxBufferEncoding, execaSync, 2);96+test('maxBuffer works with encoding buffer and stdio[*], sync', testMaxBufferEncoding, execaSync, 3);97 98 const testMaxBufferHex = async (t, fdNumber) => {63- const halfMaxBuffer = maxBuffer / 2;64- const {stdio} = await t.throwsAsync(65- execa('max-buffer.js', [`${fdNumber}`, `${halfMaxBuffer + 1}`], {...fullStdio, maxBuffer, encoding: 'hex'}),66- );67- t.is(stdio[fdNumber], Buffer.from('.'.repeat(halfMaxBuffer)).toString('hex'));99+ const length = maxBuffer / 2;100+ const {stdio} = await runMaxBuffer(t, execa, fdNumber, {length, encoding: 'hex'});101+ t.is(stdio[fdNumber], Buffer.from(getExpectedOutput(length)).toString('hex'));102 };103 104 test('maxBuffer works with other encodings and stdout', testMaxBufferHex, 1);105 test('maxBuffer works with other encodings and stderr', testMaxBufferHex, 2);106 test('maxBuffer works with other encodings and stdio[*]', testMaxBufferHex, 3);107 108+const testMaxBufferHexSync = async (t, fdNumber) => {109+ const length = maxBuffer / 2;110+ const {stdio} = await getMaxBufferSubprocess(execaSync, fdNumber, {length, encoding: 'hex'});111+ t.is(stdio[fdNumber], Buffer.from(getExpectedOutput(length + 1)).toString('hex'));112+};113+114+test('maxBuffer ignores other encodings and stdout, sync', testMaxBufferHexSync, 1);115+test('maxBuffer ignores other encodings and stderr, sync', testMaxBufferHexSync, 2);116+test('maxBuffer ignores other encodings and stdio[*], sync', testMaxBufferHexSync, 3);117+118 const testNoMaxBuffer = async (t, fdNumber) => {75- const subprocess = execa('max-buffer.js', [`${fdNumber}`, `${maxBuffer}`], {...fullStdio, buffer: false});76- const [result, output] = await Promise.all([119+ const subprocess = getMaxBufferSubprocess(execa, fdNumber, {buffer: false});120+ const [{stdio}, output] = await Promise.all([121 subprocess,122 getStream(subprocess.stdio[fdNumber]),123 ]);80- t.is(result.stdio[fdNumber], undefined);81- t.is(output, '.'.repeat(maxBuffer));124+ t.is(stdio[fdNumber], undefined);125+ t.is(output, getExpectedOutput(maxBuffer + 1));126 };127 128 test('do not buffer stdout when `buffer` set to `false`', testNoMaxBuffer, 1);129 test('do not buffer stderr when `buffer` set to `false`', testNoMaxBuffer, 2);130 test('do not buffer stdio[*] when `buffer` set to `false`', testNoMaxBuffer, 3);131 132 const testNoMaxBufferSync = (t, fdNumber) => {89- const {stdio} = execaSync('max-buffer.js', [`${fdNumber}`, `${maxBuffer}`], {...fullStdio, buffer: false});133+ const {stdio} = getMaxBufferSubprocess(execaSync, fdNumber, {buffer: false});134 t.is(stdio[fdNumber], undefined);135 };136 137 // @todo: add a test for fd3 once the following Node.js bug is fixed.138 // https://github.com/nodejs/node/issues/52338139 test('do not buffer stdout when `buffer` set to `false`, sync', testNoMaxBufferSync, 1);140 test('do not buffer stderr when `buffer` set to `false`, sync', testNoMaxBufferSync, 2);141 98-const testNoMaxBufferOption = async (t, fdNumber) => {99- const length = maxBuffer + 1;100- const subprocess = execa('max-buffer.js', [`${fdNumber}`, `${length}`], {...fullStdio, maxBuffer, buffer: false});101- const [result, output] = await Promise.all([102- subprocess,103- getStream(subprocess.stdio[fdNumber]),104- ]);105- t.is(result.stdio[fdNumber], undefined);106- t.is(output, '.'.repeat(length));107-};108-109-test('do not hit maxBuffer when `buffer` is `false` with stdout', testNoMaxBufferOption, 1);110-test('do not hit maxBuffer when `buffer` is `false` with stderr', testNoMaxBufferOption, 2);111-test('do not hit maxBuffer when `buffer` is `false` with stdio[*]', testNoMaxBufferOption, 3);112-142 const testMaxBufferAbort = async (t, fdNumber) => {114- const subprocess = execa('max-buffer.js', [`${fdNumber}`, `${maxBuffer + 1}`], {...fullStdio, maxBuffer});143+ const subprocess = getMaxBufferSubprocess(execa, fdNumber);144 await Promise.all([145 t.throwsAsync(subprocess, {message: maxBufferMessage}),146 t.throwsAsync(getStream(subprocess.stdio[fdNumber]), {code: 'ERR_STREAM_PREMATURE_CLOSE'}),147 ]);5 unmodified linesmodified:index.d.ts+22 added-4 removed
1415 unmodified lines1416 1417 /**1418 Same as `execa()` but synchronous.1419 1420-Returns or throws a `subprocessResult`. The `subprocess` is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), `.pipe()`, `.iterable()`, `.readable()`, `.writable()`, `.duplex()` and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.1420+Returns or throws a `subprocessResult`. The `subprocess` is not returned: its methods and properties are not available.1421 1422-Cannot use the following options: `cleanup`, `detached`, `ipc`, `serialization`, `cancelSignal` and `forceKillAfterDelay`. `result.all` is not interleaved. Also, the `stdin`, `stdout`, `stderr` and `stdio` options cannot be [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async transform, a `Duplex`, or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1422+The following features cannot be used:1423+- Streams: [`subprocess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin), [`subprocess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout), [`subprocess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr), `subprocess.readable()`, `subprocess.writable()`, `subprocess.duplex()`.1424+- The `stdin`, `stdout`, `stderr` and `stdio` options cannot be [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async transform, a `Duplex`, nor a web stream. Node.js streams can be passed but only if either they [have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr), or the `input` option is used.1425+- Signal termination: [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`subprocess.pid`](https://nodejs.org/api/child_process.html#subprocesspid), `cleanup` option, `cancelSignal` option, `forceKillAfterDelay` option.1426+- Piping multiple processes: `subprocess.pipe()`.1427+- `subprocess.iterable()`.1428+- `ipc` and `serialization` options.1429+- `result.all` is not interleaved.1430+- `detached` option.1431+- The `maxBuffer` option is always measured in bytes, not in characters, lines nor objects. Also, it ignores transforms and the `encoding` option.1432 1433 @param file - The program/script to execute, as a string or file URL1434 @param arguments - Arguments to pass to `file` on execution.1435 @returns A `subprocessResult` object103 unmodified lines1539 1540 /**1541 Same as `execaCommand()` but synchronous.1542 1534-Returns or throws a `subprocessResult`. The `subprocess` is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), `.pipe()`, `.iterable()`, `.readable()`, `.writable()`, `.duplex()` and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.1543+Returns or throws a `subprocessResult`. The `subprocess` is not returned: its methods and properties are not available.1544 1536-Cannot use the following options: `cleanup`, `detached`, `ipc`, `serialization`, `cancelSignal` and `forceKillAfterDelay`. `result.all` is not interleaved. Also, the `stdin`, `stdout`, `stderr` and `stdio` options cannot be [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async transform, a `Duplex`, or a web stream. Node.js streams must have a file descriptor unless the `input` option is used.1545+The following features cannot be used:1546+- Streams: [`subprocess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin), [`subprocess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout), [`subprocess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr), `subprocess.readable()`, `subprocess.writable()`, `subprocess.duplex()`.1547+- The `stdin`, `stdout`, `stderr` and `stdio` options cannot be [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async transform, a `Duplex`, nor a web stream. Node.js streams can be passed but only if either they [have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr), or the `input` option is used.1548+- Signal termination: [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`subprocess.pid`](https://nodejs.org/api/child_process.html#subprocesspid), `cleanup` option, `cancelSignal` option, `forceKillAfterDelay` option.1549+- Piping multiple processes: `subprocess.pipe()`.1550+- `subprocess.iterable()`.1551+- `ipc` and `serialization` options.1552+- `result.all` is not interleaved.1553+- `detached` option.1554+- The `maxBuffer` option is always measured in bytes, not in characters, lines nor objects. Also, it ignores transforms and the `encoding` option.1555 1556 @param command - The program/script to execute and its arguments.1557 @returns A `subprocessResult` object1558 @throws A `subprocessResult` error128 unmodified linesmodified:readme.md+11 added-2 removed
315 unmodified lines316 #### execaSync\`command\`317 318 Same as [`execa()`](#execafile-arguments-options) but synchronous.319 320-Returns or throws a [`subprocessResult`](#subprocessResult). The [`subprocess`](#subprocess) is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), [`.pipe()`](#pipefile-arguments-options), [`.iterable()`](#iterablereadableoptions), [`.readable()`](#readablereadableoptions), [`.writable()`](#writablewritableoptions), [`.duplex()`](#duplexduplexoptions) and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.320+Returns or throws a [`subprocessResult`](#subprocessResult). The [`subprocess`](#subprocess) is not returned: its methods and properties are not available.321 322-Cannot use the following options: [`cleanup`](#cleanup), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`cancelSignal`](#cancelsignal) and [`forceKillAfterDelay`](#forcekillafterdelay). [`result.all`](#all-1) is not interleaved. Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1) and [`stdio`](#stdio-1) options cannot be [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async [transform](docs/transform.md), a [`Duplex`](docs/transform.md#duplextransform-streams), or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.322+The following features cannot be used:323+- Streams: [`subprocess.stdin`](https://nodejs.org/api/child_process.html#subprocessstdin), [`subprocess.stdout`](https://nodejs.org/api/child_process.html#subprocessstdout), [`subprocess.stderr`](https://nodejs.org/api/child_process.html#subprocessstderr), [`subprocess.readable()`](#readablereadableoptions), [`subprocess.writable()`](#writablewritableoptions), [`subprocess.duplex()`](#duplexduplexoptions).324+- The [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1) and [`stdio`](#stdio-1) options cannot be [`'overlapped'`](https://nodejs.org/api/child_process.html#optionsstdio), an async iterable, an async [transform](docs/transform.md), a [`Duplex`](docs/transform.md#duplextransform-streams), nor a web stream. Node.js streams can be passed but only if either they [have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr), or the `input` option is used.325+- Signal termination: [`subprocess.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`subprocess.pid`](https://nodejs.org/api/child_process.html#subprocesspid), [`cleanup`](#cleanup) option, [`cancelSignal`](#cancelsignal) option, [`forceKillAfterDelay`](#forcekillafterdelay) option.326+- Piping multiple processes: [`subprocess.pipe()`](#pipefile-arguments-options).327+- [`subprocess.iterable()`](#iterablereadableoptions).328+- [`ipc`](#ipc) and [`serialization`](#serialization) options.329+- [`result.all`](#all-1) is not interleaved.330+- [`detached`](#detached) option.331+- The [`maxBuffer`](#maxbuffer) option is always measured in bytes, not in characters, [lines](#lines) nor [objects](docs/transform.md#object-mode). Also, it ignores transforms and the [`encoding`](#encoding) option.332 333 #### $(file, arguments?, options?)334 335 `file`: `string | URL`\899 unmodified lines