grpc / grpc-node

gRPC for Node.js
https://grpc.io
Apache License 2.0
4.4k stars 629 forks source link

Servers send grpc-message trailer even when no error #2769

Open jhump opened 1 month ago

jhump commented 1 month ago

The gRPC protocol spec has this to say about the “grpc-message” trailer, which is optional (unlike “grpc-status”):

The value portion of Status-Message is conceptually a Unicode string description of the error

So when there is no error (i.e. the “grpc-status” trailer value is “0”), it is incorrect to include this; there is no error for such a string to describe.

The server in this repo always emits a “grpc-message” trailer, even on success. The source of the message should be the application, which indicates both the status code and the message when errors occur. But in this case, the application has not actually indicated an error message. The string “OK” gets used unconditionally for the value of this trailer.

FWIW, this behavior differs from the behavior of other gRPC implementations (C++, Java, and Go), which only include such a trailer for errors. I think their behavior is correct per my interpretation of the spec.

murgatroid99 commented 1 month ago

The spec doesn't say that it is incorrect to include the message with an OK status. At most, it implies that it is unnecessary to do so.