{"record":{"id":"b9ec7a5ed5473e22","repo":"denoland/deno","slug":"err-invalid-arg-value-b9ec7a","errorCode":"ERR_INVALID_ARG_VALUE","errorMessage":"The argument 'stdio' is invalid. Received ${inspected}","messagePattern":"The argument 'stdio' is invalid\\. Received (.+?)","errorType":"error_code","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/internal/child_process.ts","lineNumber":209,"sourceCode":"}\n\nfunction stdioStringToArray(\n  stdio,\n  channel,\n) {\n  const options = [];\n\n  switch (stdio) {\n    case \"ignore\":\n    case \"overlapped\":\n    case \"pipe\":\n      ArrayPrototypePush(options, stdio, stdio, stdio);\n      break;\n    case \"inherit\":\n      ArrayPrototypePush(options, stdio, stdio, stdio);\n      break;\n    default:\n      throw new ERR_INVALID_ARG_VALUE(\"stdio\", stdio);\n  }\n\n  if (channel) ArrayPrototypePush(options, channel);\n\n  return options;\n}\n\nconst kClosesNeeded = Symbol(\"_closesNeeded\");\nconst kClosesReceived = Symbol(\"_closesReceived\");\nconst kCanDisconnect = Symbol(\"_canDisconnect\");\nconst kChildStdioUsedAsInput = Symbol(\"childStdioUsedAsInput\");\nconst childStdioStreamsByFd = new SafeMap();\nlet emittedShellDeprecation = false;\n\n// We only want to emit a close event for the child process when all of\n// the writable streams have closed. The value of `child[kClosesNeeded]` should be 1 +\n// the number of opened writable streams (note this excludes `stdin`).\nfunction maybeClose(child) {","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/internal/child_process.ts#L191-L227","documentation":"In Deno's node:child_process polyfill, stdioStringToArray() expands a shorthand string stdio option into the 3-element array [stdio, stdio, stdio]. Only 'ignore', 'overlapped', 'pipe' and 'inherit' are accepted; any other string falls to the default branch and throws ERR_INVALID_ARG_VALUE. This runs on the fork()/spawn option-normalization path.","triggerScenarios":"fork(modulePath, { stdio: 'ipc' }), stdio: 'silent', stdio: 'null', stdio: 'inherit ' (trailing space), or any typo'd keyword — i.e. any string shorthand outside the four valid values.","commonSituations":"Confusing spawn's legacy `silent: true` boolean with a stdio string; writing stdio: 'null' instead of 'ignore'; trying to request an IPC channel with the string 'ipc' (only valid as an array element); values built by string concatenation that pick up whitespace.","solutions":["Use one of the four valid strings: 'pipe', 'inherit', 'ignore', 'overlapped'","For IPC use the array form, e.g. stdio: ['ipc', 'pipe', 'pipe'], or just call fork() which wires IPC for you","For per-fd control pass a full array: stdio: ['inherit', 'pipe', 'ignore']","Trim/validate the string before passing if it comes from user input or config"],"exampleFix":"// before\nfork(script, { stdio: 'silent' });\n\n// after\nfork(script, { silent: true });\n// or\nfork(script, { stdio: ['ignore', 'pipe', 'pipe'] });","handlingStrategy":"validation","validationCode":"const VALID = new Set(['pipe', 'inherit', 'ignore', 'overlapped']);\nfunction toStdioArray(shorthand) {\n  if (typeof shorthand === 'string' && !VALID.has(shorthand)) {\n    throw new Error(`invalid stdio shorthand '${shorthand}'; expected one of ${[...VALID].join(', ')}`);\n  }\n  return typeof shorthand === 'string' ? [shorthand, shorthand, shorthand] : shorthand;\n}","typeGuard":"const isStdioShorthand = (s) => typeof s === 'string' &&\n  ['pipe', 'inherit', 'ignore', 'overlapped'].includes(s);","tryCatchPattern":"try { fork(script, { stdio: mode }); } catch (err) {\n  if (err?.code === 'ERR_INVALID_ARG_VALUE' && /stdio/.test(err.message)) {\n    // fall back to explicit array form\n    fork(script, { stdio: ['pipe', 'pipe', 'pipe'] });\n  }\n}","preventionTips":["Remember the four valid shorthands: pipe, inherit, ignore, overlapped","'ipc' is never valid as a string shorthand — use an array element or fork()","Trim and lowercase-check config-sourced strings against the whitelist"],"tags":["child-process","stdio","node-compat","deno","fork"],"backgroundTag":"invalid-stdio-option","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}