Repository navigation
fix(git): report why cat-file failed, not the broken pipe to it - #36
Merged
Merged
Conversation
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.
Problem
When gitview reads files from another machine and the connection drops, the person should see "machine … is unreachable". Instead they sometimes see
Broken pipe (os error 32). gitview sends the paths it wants togit cat-filethrough its input. If the remote command has already exited (hc lost the connection), that write fails, and?returned the pipe error before gitview read the command's exit status and stderr.The same race makes
a_diff_whose_reads_fail_there_is_an_error_not_a_wrong_difffail on CI now and then. It failed on #30 and #35, and on main after #35 merged.Fix
cat_filekeeps the write's result, waits for git, and reports git's own failure first. A write error is still an error when git exits successfully.Proof
To force the race, I put a temporary 300 ms pause before the write, so the remote command always exits first (not committed):
{"error":"Broken pipe (os error 32)"}On Rust 1.100:
cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo testpass.