{"record":{"id":"b73ed2d4eccb0e91","repo":"denoland/deno","slug":"invalid-stdio-count","errorCode":null,"errorMessage":"Invalid stdio count","messagePattern":"Invalid stdio count","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"runtime/subprocess_windows/src/process_stdio.rs","lineNumber":253,"sourceCode":"      size_of::<HANDLE>(),\n    )\n  }\n}\n\n#[derive(Debug, Clone, Copy)]\npub enum StdioContainer {\n  Ignore,\n  InheritFd(i32),\n  RawHandle(HANDLE),\n}\n\n#[inline(never)]\npub(crate) fn uv_stdio_create(\n  options: &SpawnOptions,\n) -> Result<StdioBuffer, std::io::Error> {\n  let mut count = options.stdio.len();\n  if count > 255 {\n    return Err(std::io::Error::new(\n      std::io::ErrorKind::InvalidInput,\n      \"Invalid stdio count\",\n    ));\n  } else if count < 3 {\n    count = 3;\n  }\n\n  let mut buffer = StdioBuffer::new(count);\n\n  for i in 0..count {\n    let fdopt = if i < options.stdio.len() {\n      options.stdio[i]\n    } else {\n      StdioContainer::Ignore\n    };\n\n    match fdopt {\n      StdioContainer::RawHandle(handle) => {","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/runtime/subprocess_windows/src/process_stdio.rs#L235-L271","documentation":"uv_stdio_create() sizes the child's stdio buffer from options.stdio. libuv/CreateProcess support at most 255 streams, so a stdio vector longer than 255 entries is rejected up front with InvalidInput 'Invalid stdio count' (vectors shorter than 3 are padded up to stdin/stdout/stderr).","triggerScenarios":"Spawning with a stdio array longer than 255 entries - reachable from Node-compat child_process.spawn({ stdio: [...many] }) or from programmatic code that generates one stdio entry per open file.","commonSituations":"A loop bug that appends one \"pipe\" per iteration; porting code that wires dozens or hundreds of fds into a child; copy-paste expansion of stdio configuration arrays.","solutions":["Trim the stdio vector to the streams you actually use (normally 3: stdin, stdout, stderr)","Fix the loop that generates one stdio entry per item","Pass extra data through files or pipes set up after spawn instead of extra stdio slots"],"exampleFix":"// before\nconst stdio = openFiles.map(() => \"pipe\"); // 300 entries\nspawn(prog, { stdio: [\"pipe\", \"pipe\", \"pipe\", ...stdio] });\n\n// after\nspawn(prog, { stdio: [\"pipe\", \"pipe\", \"pipe\"] });","handlingStrategy":"validation","validationCode":"if (stdio.length > 255) {\n  throw new Error(`stdio count ${stdio.length} exceeds the Windows limit of 255`);\n}","typeGuard":"const isWithinStdioLimit = (stdio: unknown[]): stdio is unknown[] =>\n  stdio.length <= 255;","tryCatchPattern":null,"preventionTips":["Keep stdio to the three standard streams unless a specific fd is required","Assert on stdio length when it is generated programmatically","Move bulk data transfer to files or post-spawn pipes"],"tags":["windows","subprocess","stdio","limits"],"backgroundTag":"stdio-limit-exceeded","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}