Skip to content

EOF when calling Send for client streams #961

Closed
@gustavocovas

Description

@gustavocovas

@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:

  1. 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.
  2. The back-end service receives the RPC call and returns the expected status.
  3. If the gateway is not done processing the request, the generated code calls stream.Send, which returns io.EOF, as described in the docs.
  4. The returned io.EOF results in a 500 status, instead of a 401.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions