-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix grpc status headers #2973
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
Fix grpc status headers #2973
Conversation
@FliegenKLATSCH Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@FliegenKLATSCH Thank you for signing the Contributor License Agreement! |
Can you add a test? @abelsromero @Albertoimpl can you review |
@spencergibb Any hints on how I could set trailing headers for a test case? Doesn't seem to be easy :/ |
I don't. Let's wait for my co-workers tagged above to respond |
Thanks for the ping @spencergibb, and thanks a lot @FliegenKLATSCH for the contribution and for wanting to improve our tests around it. For headers, it should be something like this: https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/header/HeaderServerInterceptor.java For trailers what you see in the |
Thank you! Ping for review @Albertoimpl @abelsromero |
These assertions should cover the case, thanks @FliegenKLATSCH! |
@spencergibb Any intentions to merge this? Thank you! |
The test case looks useful but I don't see any changes in the implementation. What am I missing? There are some changes in Reactor Netty that will make fixing #3783 easier, so we should take the test from this PR and leave the implementation changes to be replaced by something that actually uses the trailer headers in the client response (see #3855). |
?! |
What's your point @FliegenKLATSCH? Nevermind, I get it: if (headers.containsKey(GRPC_STATUS_HEADER)) {
if (!"0".equals(headers.getFirst(GRPC_STATUS_HEADER))) {
response.setComplete(); // avoid empty DATA frame
}
} This is new. You could have said. It might still be useful along with the test (or it might have been fixed incidentally by the Reactor Netty changes). |
What you pointed out is actually more or less just a "cosmetic" fix. Not sure if there would be any effect, if there is an empty addtional frame or not. |
I added your test to #3855, and it is indeed fixed by the Reactor Netty changes. If you want an author tag, we usually use "Firstname Lastname", so let me know. |
No, I guess I am fine if that works. Just wondering if we're getting all the trailing headers from a stream, if we're just looking once at |
I added a streaming service to the integration tests in #3855. Seems to work. Can't say if there would be complications in a slow network. |
What do you mean with
Reactor Netty collects the trailer headers and emits them via The proposed fix forwards the response data then forwards the trailer headers and then completes. |
Exactly. But what happens if there is some delay between the data frames and the trailer headers? Because of packet loss or whatever reason. The code would check, if there are any, Reactor Netty might say no, because it simply did not receive them yet, or not all of them. It might be a theoretical issue, or I might be wrong.. 🤷♂️ |
No, it is not how it works: The proposed change is in #3855 in
It works the opposite: the one who is interested subscribes, when Reactor Netty has the trailer headers it will emit them. |
Ah the Mono comes from Netty.. overlooked that, thought we would get just a list there.. Thank you for the clarification! |
Fixes #2961
Headers are only set, if they are received.
In case the status comes with the first header and is an error
response.setComplete()
is called to setendStream=true
and prevent an empty DATA frame being sent. This would lead toReceived unexpected EOS on DATA frame from server
errors otherwise on the grpc client side.