client: make BidiStream receive initialization cancellation-safe#220
Closed
EffortlessSteven wants to merge 1 commit into
Closed
client: make BidiStream receive initialization cancellation-safe#220EffortlessSteven wants to merge 1 commit into
EffortlessSteven wants to merge 1 commit into
Conversation
Contributor
Author
|
Not intended for upstream yet. |
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.
What this does
Cancelling the first
BidiStream::message()while it waits for receive initialization could leaveRecvStatefailed without an underlying error. Later reads then returnedinternal("stream in failed state")even if the server completed normally.Fix: keep receive initialization inside
RecvStatewhile response headers and response-stream construction are pending. A cancelledmessage()call leaves initialization resumable by the next call, while real transport, deadline, and protocol failures remain terminal and sticky.Verification
stream in failed state, patched yields the response messagestream in failed state, patched returns the server errorDeadlineExceededstays stickyUnavailablestays stickySend/Sync/Unpinpreservedcargo test -p connectrpc --all-featurescargo test -p connectrpc --no-default-featurescargo clippy -p connectrpc --all-features --all-targets -- -D warningscargo +nightly-2026-02-27 fmt --all -- --checkRUSTDOCFLAGS=-Dwarnings cargo doc -p connectrpc --all-features --no-depsReview map
connectrpc/src/client/mod.rs: retain bidi receive initialization asAwaitingHeadersandConstructing; store terminal initialization errors asFailed(ConnectError).connectrpc/src/client/mod.rstests: pin cancellation before headers, cancellation during Connect error-body parsing, sticky failures, auto traits, and half-duplex preservation..changes/unreleased: document the user-visible cancellation-safety fix.