{"record":{"id":"d512b2447488ce5b","repo":"jdx/mise","slug":"command-output-exceeded-max-output-bytes-bytes","errorCode":null,"errorMessage":"command output exceeded {max_output_bytes} bytes","messagePattern":"command output exceeded (.+?) bytes","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd.rs","lineNumber":1383,"sourceCode":"                            let _ = tx.send(HashedProcessOutput::ReadError(\"stderr\", err)).await;\n                            break;\n                        }\n                    }\n                }\n            });\n        }\n        drop(tx);\n\n        let timeout_guard = self.timeout.map(|timeout| TimeoutGuard::new(timeout, id));\n        let mut stdout_hasher = blake3::Hasher::new();\n        let mut stderr_hasher = blake3::Hasher::new();\n        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());","sourceCodeStart":1365,"sourceCodeEnd":1401,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/cmd.rs#L1365-L1401","documentation":"While streaming a child process's stdout for hashing (execute_hashes_async), the accumulated output exceeded max_output_bytes and mise aborted with `command output exceeded <N> bytes`. This guard prevents unbounded memory/consumption when capturing command output.","triggerScenarios":"Any command executed through execute_hashes_async (used for checksummed/captured output, e.g. script/env-file execution) whose combined stdout exceeds the configured max_output_bytes cap; the check fires in the stdout arm of the consume closure.","commonSituations":"Scripts that dump very large files to stdout; verbose/debug logging enabled in an env hook; accidentally catting a large binary or log; a runaway loop printing continuously.","solutions":["Reduce the command's stdout volume (redirect to a file, quiet flags like -q/--silent).","Raise max_output_bytes at the call site/configuration if large output is expected.","Fix runaway output (loops, debug prints) in the script being executed.","Stream results to disk instead of hashing in-memory output if the data is legitimately huge."],"exampleFix":"// before (task script)\ncat huge.json\n# command output exceeded 1048576 bytes\n// after\njq -r '.key' huge.json  # or: cat huge.json > /tmp/out.json && jq -r '.key' /tmp/out.json","handlingStrategy":"validation","validationCode":"bytes=$(command | wc -c); [ \"$bytes\" -le 1048576 ] || echo 'output exceeds max_output_bytes — redirect to file'","typeGuard":null,"tryCatchPattern":"out=$(cmd 2>/dev/null | head -c 1048576) || { tail_log_file_instead; }","preventionTips":["Redirect large outputs to files instead of stdout when capturing.","Disable verbose/debug logging in scripts whose output mise captures.","Set max_output_bytes above your known worst-case output size."],"tags":["output-limit","process","stdout"],"backgroundTag":"payload-too-large","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"}