{"record":{"id":"e109c8386eeb3027","repo":"denoland/deno","slug":"piped-stdin-is-not-supported-for-this-function-us","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":646,"sourceCode":"  }\n}\n\nfunction spawnInner(command, {\n  args = [],\n  cwd = undefined,\n  clearEnv = false,\n  env = { __proto__: null },\n  uid = undefined,\n  gid = undefined,\n  signal = undefined,\n  stdin = \"null\",\n  stdout = \"piped\",\n  stderr = \"piped\",\n  windowsRawArguments = false,\n  [kNeedsNpmProcessState]: needsNpmProcessState = false,\n} = { __proto__: null }) {\n  if (stdin === \"piped\") {\n    throw new TypeError(\n      \"Piped stdin is not supported for this function, use 'Deno.Command().spawn()' instead\",\n    );\n  }\n  // Bypass ChildProcess and ReadableStream machinery. Creating streams\n  // just to immediately collect all data has significant overhead that\n  // causes RSS growth in tight loops. Reading directly from the resource\n  // IDs avoids that overhead.\n  const child = op_spawn_child({\n    cmd: pathFromURL(command),\n    args: ArrayPrototypeMap(args, String),\n    cwd: pathFromURL(cwd),\n    clearEnv,\n    argv0: undefined,\n    env: ObjectEntries(env),\n    uid,\n    gid,\n    stdin,\n    stdout,","sourceCodeStart":628,"sourceCodeEnd":664,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/process/40_process.js#L628-L664","documentation":"spawnInner (backing new Deno.Command(...).output() and Deno.spawnAndWait) rejects stdin: \"piped\" with a TypeError before spawning. A piped stdin only makes sense when you can write to the child while it runs, which requires a live ChildProcess from spawn(); output()-style helpers only return after exit, so the pipe would be unusable.","triggerScenarios":"new Deno.Command(\"cat\", { stdin: \"piped\" }).output(), or Deno.spawnAndWait(\"cat\", { stdin: \"piped\" }); also copying options objects built for spawn() straight into an output() call.","commonSituations":"Reusing one shared options object for both streaming and one-shot code paths; porting scripts that previously used Deno.run with customStdin; trying to feed input without knowing about spawn()+child.stdin.","solutions":["Switch to spawn(): const child = cmd.spawn(); then write to child.stdin.getWriter() and close it","Change stdin to \"inherit\", \"null\", or omit it when the child needs no input","For one-shot input, write input via child.stdin after spawn(), or use an OS-level pipe/stdin file instead of stdin: \"piped\" in output()"],"exampleFix":"// before\nconst out = await new Deno.Command(\"cat\", { stdin: \"piped\" }).output(); // TypeError\n\n// after\nconst child = new Deno.Command(\"cat\", { stdin: \"piped\", stdout: \"piped\" }).spawn();\nconst w = child.stdin.getWriter();\nawait w.write(new TextEncoder().encode(\"hello\"));\nawait w.close();\nconst out = await child.output();","handlingStrategy":"validation","validationCode":"const { stdin: _s, ...opts } = spawnOpts; // strip piped stdin\nconst out = await new Deno.Command(cmd, opts).output();\n// or branch: if you need to write input, use spawn() instead","typeGuard":"const needsStdin = (o: Deno.CommandOptions | undefined): boolean => o?.stdin === \"piped\";","tryCatchPattern":null,"preventionTips":["Never share an options object containing stdin: \"piped\" with output()-style calls","Branch on whether input must be written: spawn() + child.stdin, else output()","Let TypeScript guide you: the output() result has no stdin handle, so piped stdin there is always a bug"],"tags":["deno","child-process","stdin","piped-stdin","output","spawn"],"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"}