{"record":{"id":"2a6af38b4c2eaa81","repo":"jdx/mise","slug":"failed-to-read-command-stream-err","errorCode":null,"errorMessage":"failed to read command {stream}: {err}","messagePattern":"failed to read command (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd.rs","lineNumber":1395,"sourceCode":"        let mut output_bytes = 0usize;\n        let mut consume = |output: HashedProcessOutput| -> Result<()> {\n            match output {\n                HashedProcessOutput::Stdout(bytes) => {\n                    output_bytes = output_bytes.saturating_add(bytes.len());\n                    if output_bytes > max_output_bytes {\n                        bail!(\"command output exceeded {max_output_bytes} bytes\");\n                    }\n                    stdout_hasher.update(&bytes);\n                }\n                HashedProcessOutput::Stderr(bytes) => {\n                    output_bytes = output_bytes.saturating_add(bytes.len());\n                    if output_bytes > max_output_bytes {\n                        bail!(\"command output exceeded {max_output_bytes} bytes\");\n                    }\n                    stderr_hasher.update(&bytes);\n                }\n                HashedProcessOutput::ReadError(stream, err) => {\n                    bail!(\"failed to read command {stream}: {err}\");\n                }\n            }\n            Ok(())\n        };\n        let mut status = None;\n        let mut wait = Box::pin(cp.wait());\n        loop {\n            tokio::select! {\n                result = &mut wait, if status.is_none() => {\n                    status = Some(result?);\n                    break;\n                }\n                output = rx.recv() => {\n                    let Some(output) = output else {\n                        status = Some(wait.await?);\n                        break;\n                    };\n                    if let Err(err) = consume(output) {","sourceCodeStart":1377,"sourceCodeEnd":1413,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/cmd.rs#L1377-L1413","documentation":"While consuming hashed output streams, a read on the child's stdout or stderr pipe failed; cmd.rs surfaces it as `failed to read command <stream>: <err>` (stream identifies stdout/stderr, err is the underlying IO error). This usually means the pipe was broken or the OS returned an error mid-read.","triggerScenarios":"execute_hashes_async reading a child's stdout/stderr when the OS read fails: the child killed its own end of the pipe abnormally, the fd was closed unexpectedly, or an OS-level IO error (EIO) occurred — distinct from clean EOF (Ok(None)), which breaks the loop normally.","commonSituations":"Child process crashing while output is still buffered; running out of file descriptors or pipe buffer resources; processes that close their stdio handles unexpectedly; sandboxed/limited CI environments killing processes.","solutions":["Check the embedded IO error (`err`) for the root cause (EPIPE/EIO etc.).","Re-run the command; transient pipe errors often disappear on retry.","Investigate whether the child process crashes mid-execution (core dumps, dmesg, OOM killer logs).","Check system resource limits (ulimit -n, pipe/memory pressure) in constrained environments."],"exampleFix":"// before: child crashes mid-output\nmise run flaky-task\n# failed to read command stdout: Broken pipe (os error 32)\n// after: fix child or raise limits\nulimit -n 4096 && mise run flaky-task","handlingStrategy":"retry","validationCode":"# check resources before running\nulimit -n; df -h /tmp; free -m","typeGuard":null,"tryCatchPattern":"for attempt in 1 2 3; do mise run task && break || { [ $attempt -lt 3 ] && sleep 2; }; done","preventionTips":["Keep systems from killing children mid-run (watch OOM killer, sandbox limits).","Raise fd limits in CI containers that run many parallel commands.","Retry transient IO errors — they are often one-off."],"tags":["io","pipe","process"],"backgroundTag":"broken-pipe","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}