-
Notifications
You must be signed in to change notification settings - Fork 16
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
trailers are not being passed correctly in the response #139
Comments
@rauanmayemir thanks for raising the issue. I'm going to add the conformance test suite to improve coverage which will hopefully highlight this issue and allow us to investigate solutions. Issues grpc/grpc-go#2206 and grpc/grpc-go#553 look like the cause so ideally we could upstream a fix if we are unable to workaround it. |
Wondering if there's any chance to have this fixed soon. I've been holding off on adopting vanguard due to this issue breaking my frontend that depends on gRPC-Web. To understand response state we need to parse (I could take a stab and try fixing this, but I don't know where to start) |
@rauanmayemir, I started looking into this and am trying to figure out what exactly the issue is. The screenshot above and the linked issue don't really describe an error. Is it that application-set trailers are missing from the response? Or are the actual status and details failing to come across (like an RPC that should fail is being incorrectly considered a success)? The linked issue just describes that the handler never emits trailers-only responses. But such responses are not necessarily expected/required by the spec -- separating them into headers and trailers is acceptable (and, in fact, they must be separated if the application has set any custom headers since metadata in a trailers-only response are interpreted as trailers). I'll keep playing with this to see if I can reproduce some sort of problem, but I think I'm uncertain from the above on exactly what the expected behavior is and what's going wrong. |
Thank you, I’ll try to reproduce and find the issue as well. The issue here is that headers are being garbled like in the screenshot (it’s from grpcui, I’ll try to find out what’s actually happening). |
@rauanmayemir, the screenshot does not seem to show garbled headers. What is it you are expecting them to look like? Did the application attempt to send custom header or trailer metadata that is missing? |
@jhump It's the obvious part here:
What I should have seen is:
Also notice |
@rauanmayemir, the So is the issue that the
That looks fine. Are the |
If I remember correctly, it will interpret rpc as failed. I think I'm confusing grpcui's visual presentation with grpc-web/grpc-json transcoding of headers and trailers into http headers. But it still bothers me that some requests correctly show my trailers and headers separately (i.e: headers, body, trailers), but for unsuccessful requests with Let me get back to you after I try grpc-web/grpc-json requests instead of grpcui. |
Do you mind including a more full screenshot to demonstrate what you mean? The one above seems to be clipped and only shows the headers. There should be more, like an error and optional trailers, below that. This could also potentially be a bug/quirk with how |
That’s what I meant, there is only what is displayed in the screenshot. Since this is an unsuccessful response, there is no body. I have no idea what is headers and what is trailers, all of it is in there together.
This could also potentially be a bug/quirk with how grpcui renders these responses.
Very possible, which is why I’m coming up with a repro so the metadata can be textual.
…On 7 Jan 2025 at 22:32 +0500, Joshua Humphries ***@***.***>, wrote:
> but for unsuccessful requests with ServeHttp trailers and headers turn into a mess.
Do you mind including a more full screenshot to demonstrate what you mean? The one above seems to be clipped and only shows the headers. There should be more, like an error and optional trailers, below that. This could also potentially be a bug/quirk with how grpcui renders these responses.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
There is indeed an issue with the trailers, they are being included to response headers in a weird way. And here's a variant with
@jhump Btw, it seems like vanguard is actually the one adding those headers here: Line 69 in 9c8fc53
It is unclear to me why is it done. |
Tried for `grpc-web:
I'm guessing As you can see here, |
@rauanmayemir, this all looks fine. The first example isn't "hoisting" anything into headers. It is simply pre-declaring some of the trailer fields. This is an implementation detail of Go's "net/http" package: in order to make sure the package will send trailers separately from headers when there is no response body, one must predeclare a trailer. That "trailer" response header is part of the HTTP standard: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Trailer You will not see this with the grpc-web protocol because grpc-web does not actually use trailers: the trailer metadata and status are included in a special message at the end of the response body (because browsers APIs generally don't support trailers, so the only way for grpc-web browser JavaScript client code to observe the status is to put it in the body). The reason you may not see this with other gRPC server implementations is that they don't use the "net/http" library, so don't have the same caveat imposed to make sure trailers are correctly sent. In some cases, the "net/http"-based implementation could send what's called a "trailers-only" response -- in this case, the response headers contain any trailing metadata and the status keys (designed to make the response more compact over HTTP/2 when there is no response body data and the application isn't trying to send custom headers separately from custom trailers). I have a branch where I was working on adding that to grpc-go, but we would likely need more work in vanguard-go, too. Vanguard uses "net/http", and then requires the use of
Yes, Vanguard will do that sometimes. There is more work to do in vanguard-go to have it support trailers-only responses. But this is also done in the grpc-go server when using its |
Oh, you mean I was supposed to parse trailers from the response body in the first place and not rely on http headers. I checked the protocol and you are right. I thought it was a bug in grpc-go when in fact it's a 'bug' in envoy: for trailer-only responses it hoists Should vanguard follow the protocol then? It shouldn't be very hard to parse trailers from the body and as a bonus, it will support larger values. |
OTOH, browser features section for CORS mentions |
I'm getting really confused. In case of non-OK responses vanguard DOES NOT fail, it will indeed add The only instance where it differs from envoy is when grpc-status is 0. Envoy will still add it, but vanguard won't. Should we close this issue? 😄 |
Trailers are being broken in the response when grpc is served behind vanguard:
I'm assuming that under the hood vanguard essentially wraps
grpcServer.ServeHttp
which leads to the same outcome when used as is without vanguard. There is a similar issue that was never really solved: grpc/grpc-go#2206.The text was updated successfully, but these errors were encountered: