{"record":{"id":"ca4c339b33b2c67e","repo":"denoland/deno","slug":"piped-stdin-is-not-supported-for-this-function-us-ca4c33","errorCode":null,"errorMessage":"Piped stdin is not supported for this function, use 'Deno.Command.spawn()' instead","messagePattern":"Piped stdin is not supported for this function, use 'Deno\\.Command\\.spawn\\(\\)' instead","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/process/40_process.js","lineNumber":802,"sourceCode":"      }\n      return result.stderr;\n    },\n  };\n  return output;\n}\n\nclass Command {\n  #command;\n  #options;\n\n  constructor(command, options) {\n    this.#command = command;\n    this.#options = options;\n  }\n\n  output() {\n    if (this.#options?.stdin === \"piped\") {\n      throw new TypeError(\n        \"Piped stdin is not supported for this function, use 'Deno.Command.spawn()' instead\",\n      );\n    }\n    return spawnInner(this.#command, this.#options);\n  }\n\n  outputSync() {\n    if (this.#options?.stdin === \"piped\") {\n      throw new TypeError(\n        \"Piped stdin is not supported for this function, use 'Deno.Command.spawn()' instead\",\n      );\n    }\n    return spawnSyncInner(this.#command, this.#options);\n  }\n\n  spawn() {\n    const options = {\n      __proto__: null,","sourceCodeStart":784,"sourceCodeEnd":820,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/process/40_process.js#L784-L820","documentation":"Deno.Command.prototype.output() rejects stdin: \"piped\" with a TypeError because output() resolves only after the child exits, leaving no way to write to a piped stdin. To feed a process input you must keep a live ChildProcess from spawn() and use its .stdin WritableStream.","triggerScenarios":"const cmd = new Deno.Command(\"cat\", { stdin: \"piped\" }); await cmd.output(); — also any shared options object with stdin: \"piped\" passed to a Command whose .output() is later called.","commonSituations":"Building one Command/options object and wanting both interactive writes and a final result; porting from APIs where exec accepted stdin; wrappers that offer either output() or spawn() behind the same options.","solutions":["Call cmd.spawn() instead of cmd.output(), write to child.stdin, then await child.output() for the collected result","Drop stdin: \"piped\" (use \"inherit\"/\"null\") if the child needs no input","Split your options: one preset without piped stdin for output(), one with it for spawn()"],"exampleFix":"// before\nconst cmd = new Deno.Command(\"cat\", { stdin: \"piped\" });\nconst out = await cmd.output(); // TypeError\n\n// after\nconst cmd = new Deno.Command(\"cat\", { stdin: \"piped\", stdout: \"piped\" });\nconst child = cmd.spawn();\nconst w = child.stdin.getWriter();\nawait w.write(new TextEncoder().encode(\"hello\"));\nawait w.close();\nconst out = await child.output();","handlingStrategy":"validation","validationCode":"function runCommand(cmd: Deno.Command, wantsStdin: boolean) {\n  if (wantsStdin) {\n    const child = cmd.spawn();\n    return { child, write: child.stdin.getWriter().write.bind(child.stdin.getWriter()) };\n  }\n  return { out: cmd.output() };\n}","typeGuard":"const needsInteractiveStdin = (o: Deno.CommandOptions | undefined): boolean => o?.stdin === \"piped\";","tryCatchPattern":null,"preventionTips":["Decide per call: spawn() for interactive stdin, output() otherwise","Never put stdin: \"piped\" into shared option presets used by output()","Write to child.stdin, close the writer, then await child.output() for the result"],"tags":["deno","deno-command","stdin","piped-stdin","output"],"backgroundTag":"piped-stdin-unsupported","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}