Skip to content

grpc stream.Recv doesn't decode errors #3320

@MichaelUrman

Description

@MichaelUrman

The error handling for unary vs streaming gRPC clients differ significantly. The upshot is if a service returns a *goa.ServiceError from a server-streaming method, the Recv method returns instead a *grpc.StatusError. If I've traced it back correctly, grpc/codegen/service_data.go's streamRecvT and grpc/codegen/client.go's clientEndpointInitT show the difference. From the clientEndpointInitT code I see something like this:

		res, err := inv.Invoke(ctx, v)
		if err != nil {
			resp := goagrpc.DecodeError(err)
			switch message := resp.(type) {
			case *goapb.ErrorResponse:
				return nil, goagrpc.NewServiceError(message)
			default:
				return nil, goa.Fault(err.Error())
			}
		}

whereas from the streamRecvT code I see something like this:

	v, err := s.stream.Recv()
	if err != nil {
		return res, err
	}

I'm willing to craft a PR for this with a little guidance, or totally willing to leverage someone else's hard work. :) The guidance I would need is mostly whether it's safe and how much of the clientEndpointInitT's error handling can be copied into streamRecvT; the template's data type differ significantly. Assuming this is shared with server-side receive, that deserves additional attention; I've only looked at the client-side.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions