-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defer writing headers until the first message stanza is sent #275
Conversation
Gentle ping. Any updates on this? 😀 |
@@ -241,8 +239,14 @@ object ServerCalls { | |||
val rpcScope = CoroutineScope(context) | |||
rpcScope.async { | |||
val mutex = Mutex() | |||
val headersSent = AtomicBoolean(false) // enforces only sending headers once | |||
val failure = runCatching { | |||
implementation(requests).collect { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this breaks if the responses are empty. Could we at least also do the check after collection is complete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks. Added that and tests to catch that case.
Addresses #272 (see the issue for more background).
This change makes
grpc-kotlin
more consistent with the behaviour ofgrpc-java
andgrpc-go
, which don't write the HTTP/2 headers until the first response frame is sent. Current behaviour sends an empty header frame immediately, which can force downstream proxies (namely Envoy) to commit the response, which disables retry behaviour.