Repository navigation
fix(triple): reset a client stream when its context ends - #3897
Open
AsperforMias wants to merge 1 commit into
Open
AsperforMias wants to merge 1 commit into
AsperforMias wants to merge 1 commit into
Conversation
Once the response headers arrive, Go's HTTP/2 transport stops watching the request context. Canceling the context of a bidi stream after its first response therefore sent no RST_STREAM: the provider handler and its HTTP/2 stream stayed alive until the consumer closed the stream or the connection, also when request data was waiting for flow control. When the context ends, release the response, which makes the transport reset the stream, and fail the request body. The watch stops when the response ends, fails or is released. A Send or Receive cut off by the end of the context now reports Canceled or DeadlineExceeded instead of Unknown.
4 tasks done
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3897 +/- ##
============================================
+ Coverage 46.76% 61.09% +14.32%
============================================
Files 295 515 +220
Lines 17172 42450 +25278
============================================
+ Hits 8031 25935 +17904
- Misses 8287 14703 +6416
- Partials 854 1812 +958 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Nov 29, 2026
AlexStocks
approved these changes
Nov 30, 2026
4 tasks done
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.



Description
Fixes #3894
Go's HTTP/2 transport watches the request context only until the response headers arrive. After that, canceling the context of a Triple bidi stream sent no RST_STREAM: the goroutine writing the still-open request body was blocked on the body pipe, or the transport was waiting for flow-control credit, and nothing aborted the stream. The provider handler and its HTTP/2 stream stayed alive until the consumer closed the stream or the connection, although
cancel()is the usual way to stop a stream in gRPC.Changes
duplexHTTPCallwatches its context. When it ends, the call releases the response, which makes the transport reset the stream, also while it waits for flow control, and fails the request body, which wakes a blocked writer on transports that do not close it. Before the response arrives the transport already watches the context, as before.SendorReceivecut off by the end of the context reportsCanceledorDeadlineExceededinstead ofUnknown: the closed request pipe maps to the context error, and the envelope reader and writer keep coded errors in the middle of a message as they already did for the prefix.The problem is in
v3.3.2-20260910as well as ondevelop.Verification
TestCancelEndsServerStream: the consumer only cancels, before the response, after the first response, and while a 16 MiB request waits for flow control because the server stopped reading. The handler must end withcontext.Canceledand the blockedSendmust returnCanceled. The last two cases fail without the fix.TestEnvelopeKeepsCodedErrorMidMessagecovers the codes in the middle of a message.developandv3.3.2-20260910the provider handler's context ended only when the consumer process exited, 3.5 s later; with this branch it ends at the cancel and the provider seesCANCEL.Independent of #3896; the two touch different files in
protocol/triple/triple_protocol.Checklist
developmake fmtto format my codemake testto run local tests