Closed
Description
@jonasarilho and I are working on a service with a client-side streaming RPC. We noticed that grpc-gateway does not handle correctly errors that occur before it is done processing the request body. For instance:
- The gateway receives a request that will result in an UNAUTHENTICATED status from the back-end service, because of invalid credentials that will be forwarded via metadata.
- The back-end service receives the RPC call and returns the expected status.
- If the gateway is not done processing the request, the generated code calls
stream.Send
, which returnsio.EOF
, as described in the docs. - The returned
io.EOF
results in a500
status, instead of a401
.
We believe that adding a verification for io.EOF
on the generated code template should fix this issue:
if err = stream.Send(&protoReq); err != nil {
if err == io.EOF {
break
}
grpclog.Infof("Failed to send request: %v", err)
return nil, metadata, err
}
Is this solution in the right direction? Since this would be our first contribution, we appreciate help to turn this into a PR.
Thanks