Skip to content

fix: do not panic when the output pipe is closed - #1479

Merged
dsherret merged 2 commits into
mainfrom
fix/logger-broken-pipe
Nov 29, 2026
Merged

dsherret merged 2 commits into
mainfrom
fix/logger-broken-pipe

Conversation

@dsherret

@dsherret dsherret commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

The logger unwrapped the result of writing to stdout and stderr, so closing the pipe early panicked:

dprint check --incremental=false --list-different | head -1
dprint output-file-paths | head -1
  • stdout closed, command only produces output (ex. check, output-file-paths): exits quietly, which also stops the remaining work. check exits with code 20 because it only outputs files that aren't formatted, and the others with 0.
  • stdout closed, any other command (ex. fmt --diff): ignores further output and finishes the work. Exiting there could truncate a file being written on another thread.
  • stderr closed: ignores further logs. The work and exit code aren't affected. This includes printing the final error in main.rs, which used eprintln! and so could also panic.
  • Other write errors: reported on stderr once and the process exits with a non-zero code.

Tested on Windows with 3,000 files, where 0.65.0 panics and this doesn't. Not manually tested on Unix. The unit tests use a writer that fails.

@dsherret
dsherret merged commit 9b34d9c into main Nov 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant