Question about sending big error messages via "grpc-status-details-bin"

857 views
Skip to first unread message

Denis Babochenko

unread,
Jan 20, 2022, 5:52:47 AM1/20/22
to grpc.io
Hello everyone! I couldn't find a solution on google so I'm posting here:

We have a project which uses grpc-web for handling requests to a Java server from a browser client (this decision was driven by usage of Protobuf for api code generation). Therefore, requests and responses are wrapped into HTTP/2. Whenever server throws an exception, I wrap it into a Status (https://github.com/googleapis/googleapis/.../status.proto), where details is an exception wrapped into Any. This is usually a complex exception with multiple links to different entities and so on.

An error in the response is sent not in the body, but in the "grpc-status-details-bin" header, which is why, if the error is a long binary string (>4Kb), total header size gets too large, and I assume that grpc-web cuts the message down, as It says at https://github.com/grpc/grpc/.../PROTOCOL-HTTP2.md:

> Servers may limit the size of Request-Headers, with a default of 8 KiB suggested. Implementations are encouraged to compute total header size like HTTP/2's SETTINGS_MAX_HEADER_LIST_SIZE: the sum of all header fields, for each field the sum of the uncompressed field name and value lengths plus 32, with binary values' lengths being post-Base64.

So, the question is: is there any known workaround for responding with big error messages? I've thought about streaming chunked errors, but the OK response is not streamed in most cases

Denis Babochenko

unread,
Jan 20, 2022, 6:40:52 AM1/20/22
to grpc.io
Sorry, I forgot to mention that we route requests to grpc endpoints nginx, which means that Nginx itself probably fails to send response with >4Kb of headers. So a more precise question would be: is it possible to send an error in response body rather than in header?
Reply all
Reply to author
Forward
0 new messages