Repository navigation
Conversation
oldergod
force-pushed
the
bquenaudon.2026-04-16.lateflushes
branch
3 times, most recently
from
April 16, 2026 10:09
ba9575f to
c11403d
Compare
Member
Author
|
Does it look legit to you @swankjesse ? |
oldergod
force-pushed
the
bquenaudon.2026-04-16.lateflushes
branch
4 times, most recently
from
May 1, 2026 13:32
b6279d3 to
55fdcba
Compare
oldergod
marked this pull request as ready for review
May 1, 2026 13:41
oldergod
force-pushed
the
bquenaudon.2026-04-16.lateflushes
branch
from
May 6, 2026 10:49
55fdcba to
bb12bfc
Compare
oldergod
force-pushed
the
bquenaudon.2026-04-16.lateflushes
branch
from
May 14, 2026 15:26
bb12bfc to
7720d10
Compare
oldergod
force-pushed
the
bquenaudon.2026-04-16.lateflushes
branch
2 times, most recently
from
November 2, 2026 09:57
b4cfb31 to
d441c68
Compare
The legacy adapter now starts the call when the request arrives. OkHttp's thread sends the responses, so the caller's scope only reads the request. A request channel closed with a cause now cancels the call. A canceled MessageSink now cancels the call. The blocking path no longer uses coroutines. It sends the request when the MessageSink closes. Add tests for routing, blocking, cancel, empty request, error, and clone paths.
oldergod
force-pushed
the
bquenaudon.2026-04-16.lateflushes
branch
from
November 9, 2026 17:36
d441c68 to
63b0ffd
Compare
Canceling the legacy adapter before the request arrives now fails the pending response stream. This also applies when the call was canceled before it executed. The blocking path now starts the call on the first write. Callers can read responses before they close the MessageSink.
GrpcStreamingCall.cancel() promises an IOException. The legacy adapter now uses one when the call is canceled before the request arrives.
Server streaming calls now send a duplex request body that writes the single message and closes the stream. OkHttp still writes the request and END_STREAM before it reads the response. OkHttp stops the call timeout after the response headers only for duplex requests. With this body, long server streams no longer fail when OkHttpClient.callTimeout expires.
This branch has not been deployed
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 #3370.
Server streaming calls used a duplex request body.
A background coroutine on
Dispatchers.IOwrote the request and the HTTP/2END_STREAMflag after OkHttp started the call.Many gRPC servers wait for the client's half-close before they stream responses.
This race could delay the responses by about 5 minutes.
RealGrpcServerStreamingCallnow sends a request body that writes the single message and closes the stream inwriteTo().OkHttp calls
writeTo()before it reads the response, so the server gets the complete request andEND_STREAMfirst.The body stays duplex, so OkHttp still stops
callTimeoutafter the response headers.Long server streams keep working with a finite
OkHttpClient.callTimeout, like before.Changes:
GrpcMethodhas newrequestStreamingandresponseStreamingparameters.Both default to
false.GrpcClient.newServerStreamingCall()returnsRealGrpcServerStreamingCall.GrpcClient.newStreamingCall()returnsGrpcServerStreamingCallStreamingAdapterwhenresponseStreamingistrueandrequestStreamingisfalse.newStreamingCall()for all streaming methods whenexplicitStreamingCallsis disabled.These clients get the fix after you generate them again.
GrpcServerStreamingCallStreamingAdapterstarts the call when the request arrives.OkHttp's thread sends the responses, so the caller's scope only reads the request.
It starts the call when the caller writes the request, so the caller can read responses before it closes the
MessageSink.GrpcStreamingCallServerStreamingAdapterkeeps the old delegation for theGrpcServerStreamingCall { ... }test doubles inGrpcCalls.kt.readFromResponseBodyCallback()andBlockingMessageSourcetake anonResponseMetadatacallback.Streaming and server streaming calls share them.
Release note: Server streaming gRPC calls now send the complete request and half-close before they read responses.
This prevents long delays on servers that wait for the half-close.
The
OkHttpClient.callTimeoutbehavior does not change.GrpcMethodhas newrequestStreamingandresponseStreamingparameters, and the Kotlin generator sets them.Generate clients again to get the fix for
GrpcStreamingCallserver streaming methods.