fix(core): start an interrupted stream over when the body read fails - #318
Merged
Merged
Conversation
The restart for a stream the network cut before any reply text only fired when the body ended cleanly with no completion signal. A read error on the body was skipped as a decode failure, but every error the response stream yields carries that label, and this client applies no content decoding of its own: a chunked or sized body cut short arrives exactly there. Servers frame streams chunked, so the fault the restart was written for still ended the turn. Every body read error now counts as an interruption and gets the same fresh attempt as a clean cut. The sequence fixture can frame a body chunked and close after the first chunk; the new test streams reasoning that way, is cut, and asserts the reply is started over on a second connection with the retry announced in between. It fails on the previous code with a single served connection and a truncated result.
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.
Why
The restart for a stream the network cut before any reply text (from #316) only fired when the body ended cleanly with no completion signal. A read error on the body was treated as a decode failure and skipped, but every error the response body stream yields carries that label, and this client applies no content decoding that could fail on its own. Servers frame streams chunked, and a chunked or sized body cut short surfaces as a read error, not a clean end, so the fault the restart was written for still ended the turn with the task half done.
Summary
Transfer-Encoding: chunkedand close the socket after the first chunk, which is how a cut mid-reply reaches the client from a real server.Test Plan
a_stream_cut_mid_chunk_is_started_over: reasoning streamed in a chunked body that is cut, then a full reply on the next connection. Asserts two connections served, the retry announced between the reasoning and the reply, and the finished reply alone in the result. Fails on the previous code with one connection served and a truncated result.cargo test --workspace --lockedgreen (949);cargo +1.97.0 clippy --workspace --all-targets --locked -- -D warningsclean.Greptile Summary
The client now recognizes a response-body read failure as an interrupted stream when no reply content has been emitted. The focused chunked SSE scenario confirms that reasoning from the failed attempt is followed by a retry notice and that the completed retry supplies the final reply.
Confidence Score: 5/5
Safe to merge.
The focused stream-retry coverage passed against the updated implementation and demonstrated recovery from a chunked response that closes before completion.
Files Needing Attention: None.
What T-Rex did
Reviews (1): Last reviewed commit: "fix(core): start an interrupted stream o..." | Re-trigger Greptile