Skip to content

fix(printer): ignore broken pipe on output streams#443

Open
gcomneno wants to merge 1 commit intocanonical:mainfrom
gcomneno:contrib/issue-378-broken-pipe-head
Open

fix(printer): ignore broken pipe on output streams#443
gcomneno wants to merge 1 commit intocanonical:mainfrom
gcomneno:contrib/issue-378-broken-pipe-head

Conversation

@gcomneno
Copy link
Copy Markdown
Contributor

Summary

Ignore BrokenPipeError when writing to output streams in the printer.

This avoids crashes when output is piped to an early-closing consumer (for example
head -n1) and the downstream stream closes before craft-cli finishes writing or
cleaning up the terminal/output state.

Testing

  • pytest -q tests/unit/test_printer.py -k "broken_pipe" -rs
  • pytest -q tests/unit/test_printer.py -rs
  • pytest -q tests/integration/test_messages_integration.py -k "third_party_output" -rs
  • pytest -q tests/unit/test_messages_stream_cm.py -rs
  • ruff check craft_cli/printer.py tests/unit/test_printer.py

@gcomneno gcomneno force-pushed the contrib/issue-378-broken-pipe-head branch 2 times, most recently from ca739aa to 33fa2ac Compare April 22, 2026 14:19
@gcomneno gcomneno force-pushed the contrib/issue-378-broken-pipe-head branch from 33fa2ac to b45881f Compare April 23, 2026 02:59
@gcomneno
Copy link
Copy Markdown
Contributor Author

The functional fix looks healthy: all test jobs passed. The remaining failures appear to be external to this change:

  • QA is red only in lint/ty on pre-existing diagnostics outside this PR's diff
  • Check policy is red in OSV-scanner due to pytest 9.0.2 reported from the generated requirements artifact

@gcomneno gcomneno marked this pull request as ready for review May 8, 2026 17:35
@gcomneno gcomneno requested a review from tigarmo as a code owner May 8, 2026 17:35
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