Repository navigation
fix: don't abort when stderr or stdout is closed early (#40) - #44
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The token-budget truncation notice can still convert a closed stdout pipe into a nonzero exit.
1 open finding
What changed in this PR
Prevents closed stdout/stderr pipes from panicking or prematurely aborting document generation.
Changes:
- Adds best-effort console output macros.
- Treats stdout
BrokenPipeas successful pipeline termination. - Adds end-to-end closed-pipe regression tests.
| File | Description |
|---|---|
src/console.rs |
Adds non-panicking console macros. |
src/main.rs |
Handles BrokenPipe as success. |
src/lib.rs |
Migrates console output to safe macros. |
src/markdown.rs |
Propagates parallel output pipe closure. |
src/tree.rs |
Uses safe stdout output. |
src/file_utils.rs |
Uses safe stderr prompting. |
src/content_filter.rs |
Uses safe skip reporting. |
src/config.rs |
Uses safe configuration warnings. |
src/cache.rs |
Uses safe migration notices. |
tests/test_closed_pipes.rs |
Tests closed stdout/stderr behavior. |
CHANGELOG.md |
Documents the fix. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Owner
Author
|
Addressed review: the truncation-notice write now also records BrokenPipe. Note: with a reader that is already gone, the header write fails first, so the added token-budget test is a sanity check; the mid-stream case is covered by the shared |
This was referenced Oct 11, 2026
… site (no helper module)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #40.
consolemodule witherrln!/err!/outln!that drop write errors; all non-testeprintln!/println!calls use them, so2>&1 | head -3no longer panics (exit 101).BrokenPipewhile writing the document to-o -is reported asBrokenPipe(not a pile of per-file errors) andmainexits 0, like other pipeline tools.Follow-up: the demo script (#43) pipes through
sed -nbecause of this bug; it can go back toheadafter this lands.Note: CHANGELOG gets an
## Unreleasedentry; later PRs in this series add to the same section, so merge in order or ask me to rebase.