Skip to content
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

Merged
merged 6 commits into from
Oct 1, 2021

Conversation

rwbergstrom
Copy link
Contributor

Addresses #272 (see the issue for more background).

This change makes grpc-kotlin more consistent with the behaviour of grpc-java and grpc-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.

@ikhoon
Copy link
Contributor

ikhoon commented Sep 27, 2021

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 {
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

@jamesward jamesward merged commit 831370b into grpc:master Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants