Skip to content
This repository was archived by the owner on Apr 11, 2026. It is now read-only.

Commit be00eb7

Browse files
z23ccclaude
andcommitted
fix: handle broken pipe gracefully (exit 0 instead of panic)
Catches "Broken pipe" / "os error 32" panics from piped commands like `flowctl ... | head -1` and exits cleanly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2bfcd45 commit be00eb7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

  • flowctl/crates/flowctl-cli/src

flowctl/crates/flowctl-cli/src/main.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,17 @@ enum Commands {
408408
}
409409

410410
fn main() {
411+
// Exit cleanly on broken pipe (e.g., `flowctl ... | head -1`)
412+
// instead of panicking with "failed printing to stdout".
413+
let default_hook = std::panic::take_hook();
414+
std::panic::set_hook(Box::new(move |info| {
415+
let msg = info.to_string();
416+
if msg.contains("Broken pipe") || msg.contains("os error 32") {
417+
std::process::exit(0);
418+
}
419+
default_hook(info);
420+
}));
421+
411422
miette::set_hook(Box::new(|_| {
412423
Box::new(
413424
miette::MietteHandlerOpts::new()

0 commit comments

Comments
 (0)