{"record":{"id":"7222c85649642200","repo":"facebook/flow","slug":"failed-to-flush-status","errorCode":null,"errorMessage":"failed to flush status","messagePattern":"failed to flush status","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust_port/crates/flow_commands_connect/src/command_connect.rs","lineNumber":54,"sourceCode":"    pub show_progress: bool,\n    pub flowconfig_name: &'a str,\n    pub rerun_on_mismatch: bool,\n}\n\nfn print_status(env: &Env<'_>, message: &str) {\n    if env.quiet {\n        return;\n    }\n\n    let stderr = std::io::stderr();\n    let mut stderr = stderr.lock();\n    if env.show_progress && stderr.is_terminal() {\n        write!(stderr, \"{}: {}\", message, flow_utils_tty::spinner(false))\n            .expect(\"failed to write spinner status\");\n    } else {\n        writeln!(stderr, \"{}\", message).expect(\"failed to write status\");\n    }\n    stderr.flush().expect(\"failed to flush status\");\n}\n\nfn arg(name: &str, value: Option<&str>, arr: &mut Vec<String>) {\n    if let Some(value) = value {\n        arr.push(name.to_string());\n        arr.push(value.to_string());\n    }\n}\n\nfn flag(name: &str, value: bool, arr: &mut Vec<String>) {\n    if value {\n        arr.push(name.to_string());\n    }\n}\n\n// Starts up a flow server by literally calling flow start\nfn start_flow_server(env: &Env) -> Result<(), (String, flow_common_exit_status::FlowExitStatus)> {\n    let Env {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/facebook/flow/blob/5c865861998a8ccb7dbc82b0c1f511e9ef60c3d9/rust_port/crates/flow_commands_connect/src/command_connect.rs#L36-L72","documentation":"Raised by print_status when stderr.flush() fails after writing the status message. The write may have been buffered by the locked StderrLock, and the flush surfaces any deferred I/O error (EPIPE, ENOSPC, closed descriptor). The expect panics because a failed flush means the status output was not actually delivered.","triggerScenarios":"connect_rec or handle_missing_server calls print_status; the writeln! succeeds into the buffer, but flushing to the underlying stderr descriptor fails — typically broken pipe on a detached terminal or ENOSPC on a redirected log file.","commonSituations":"Long-running connect loops where the terminal/SSH session dies mid-run; stderr redirected to a filesystem that fills up during the run; container runtimes that close the log stream.","solutions":["Reattach to a valid stderr (live terminal or writable file) and rerun the command.","Check and free disk space if stderr is file-redirected.","Ignore the broken output stream by rerunning with --quiet / progress disabled.","Change the library to treat flush errors as non-fatal (best-effort logging)."],"exampleFix":"// before\nstderr.flush().expect(\"failed to flush status\");\n// after\nlet _ = stderr.flush(); // best-effort; status output is not critical","handlingStrategy":"try-catch","validationCode":"use std::io::Write;\nfn flush_ok() -> bool { std::io::stderr().flush().is_ok() }","typeGuard":"fn stderr_flushable() -> bool {\n    use std::io::Write;\n    std::io::stderr().flush().is_ok()\n}","tryCatchPattern":"let result = std::panic::catch_unwind(run_connect);\nif result.is_err() {\n    eprintln!(\"flush failed mid-run: check stderr target (EPIPE/ENOSPC)\");\n}","preventionTips":["Monitor free disk space where stderr logs are written.","Keep terminal/SSH sessions alive for interactive runs.","Treat stderr as best-effort: redirect important output to stdout/files.","Patch print_status-style helpers to ignore flush errors rather than panic."],"tags":["stderr","flush","io-error","panic","terminal-io"],"backgroundTag":"broken-pipe","analyzedSha":"5c865861998a8ccb7dbc82b0c1f511e9ef60c3d9","analyzedAt":"2026-09-08T04:32:53.179Z","contentChangedAt":"2026-09-08T04:32:53.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}