Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc stream.Recv doesn't decode errors #3320

Open
MichaelUrman opened this issue Jul 24, 2023 · 3 comments
Open

grpc stream.Recv doesn't decode errors #3320

MichaelUrman opened this issue Jul 24, 2023 · 3 comments

Comments

@MichaelUrman
Copy link
Contributor

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.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 30, 2023
@MichaelUrman
Copy link
Contributor Author

@douglaswth: I haven't had a time to review your recent gRPC updates. Is there any chance they address this bug?

@douglaswth
Copy link
Member

No, I don't think my changes would have addressed this issue.

@douglaswth douglaswth reopened this Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants