{"record":{"id":"f978dbf197ffcf24","repo":"facebook/flow","slug":"failed-to-write-cli-errors-f978db","errorCode":null,"errorMessage":"failed to write cli errors","messagePattern":"failed to write cli errors","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust_port/crates/flow_cli/src/status_command.rs","lineNumber":200,"sourceCode":"                .expect(\"failed to write vim/emacs errors\");\n                out.flush().expect(\"failed to flush vim/emacs errors\");\n            } else {\n                let mut cli_errors = errors.clone();\n                for (error, _) in &suppressed_errors {\n                    cli_errors.add(error.clone());\n                }\n                let stdout = std::io::stdout();\n                let mut out = stdout.lock();\n                flow_common_errors::error_utils::cli_output::print_errors(\n                    &mut out,\n                    error_flags,\n                    &None,\n                    strip_root.as_deref(),\n                    &cli_errors,\n                    &warnings,\n                    lazy_msg.as_deref(),\n                )\n                .expect(\"failed to write cli errors\");\n                out.flush().expect(\"failed to flush cli errors\");\n            }\n            flow_common_exit_status::exit(command_utils::get_check_or_status_exit_code(\n                &errors,\n                &warnings,\n                error_flags.max_warnings,\n            ))\n        }\n        server_prot::response::StatusResponse::NO_ERRORS => {\n            if args.output_json {\n                print_json(\n                    &ConcreteLocPrintableErrorSet::empty(),\n                    &ConcreteLocPrintableErrorSet::empty(),\n                    &[],\n                )\n            } else {\n                println!(\"No errors!\");\n                if let Some(msg) = &lazy_msg {","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/facebook/flow/blob/f88ac94bcf6992f5d5a158854d94613ebb92c6e6/rust_port/crates/flow_cli/src/status_command.rs#L182-L218","documentation":"For default human-readable output, `flow status` prints errors via flow_common_errors::error_utils::cli_output::print_errors to a locked stdout; this expect panics on the first write error. Projects with many errors generate many writes, so a downstream consumer that exits early (pager quit, `head`, `grep -m`) triggers BrokenPipe almost immediately, which Rust delivers as an Err because it ignores SIGPIPE.","triggerScenarios":"`flow status | head -20` on an error-heavy project; piping into less and pressing 'q'; consumer crashing mid-stream; stdout redirected to a full disk; stdout closed with `>&-`.","commonSituations":"Developers paginating or truncating large status output; CI log pipelines with early-terminating stages; disk-full CI runners.","solutions":["Write to a file and inspect that: `flow status > status.txt`.","Keep the consumer reading until EOF (no head/grep -m in the pipeline).","Free disk space when redirecting.","Maintainer fix: BrokenPipe → exit(0); surface other io errors with a diagnostic instead of a raw panic."],"exampleFix":"# before\nflow status | head -20      # head exits, flow panics on BrokenPipe\n\n# after\nflow status > /tmp/flow-status.txt && head -20 /tmp/flow-status.txt","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = flow_common_errors::error_utils::cli_output::print_errors(&mut out, error_flags, &None, strip_root.as_deref(), &cli_errors, &warnings, lazy_msg.as_deref()) {\n    if e.kind() == std::io::ErrorKind::BrokenPipe {\n        std::process::exit(0);\n    }\n    panic!(\"failed to write cli errors: {}\", e);\n}","preventionTips":["Write status output to a file and inspect it separately instead of `| head`.","Let pagers read from files, not from live flow pipes.","Drain pipelines fully; keep stdout open for the duration of the command."],"tags":["stdout","broken-pipe","cli-output","status-command","panic"],"backgroundTag":"broken-pipe","analyzedSha":"f88ac94bcf6992f5d5a158854d94613ebb92c6e6","analyzedAt":"2026-08-20T10:41:37.992Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}