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

Response with code != OK triggers both success and error callbacks #418

Closed
evanj opened this issue Dec 22, 2018 · 3 comments
Closed

Response with code != OK triggers both success and error callbacks #418

evanj opened this issue Dec 22, 2018 · 3 comments

Comments

@evanj
Copy link

evanj commented Dec 22, 2018

It is possible for gRPC responses to both have a code set to something that is not OK, and still have a response. For example, the following Python server code will return that payload, using the official gRPC implementation:

context.set_code(grpc.StatusCode.ABORTED)
context.set_details('error details')
return interop_pb2.EchoResponse(arg='message')

On the wire, this returns first the correctly serialized response object, then a headers block with grpc-status: 10 and grpc-message: error details.

When using grpc-web with this end point, the client calls the callback TWICE: First with the response message, then a second time with the error. The official NodeJS client, and the other gRPC clients I've tried this with, treat this as a gRPC error, and ignore the response message.

@adamkewley
Copy link

Having this issue with a grpc-web implementation also. Means client-side callbacks are getting called with response and error. The data sent down the wire includes a bogus response followed by an error. Python server-side also.

@adamkewley
Copy link

As a followup, once we identified that the issue we were having was because of this double-messaging thing, we dropped into the server side and made sure that context.abort(code, details) was called server-side, rather than setting the code and responding like above. The python documentation for abort is here:

https://grpc.github.io/grpc/python/grpc.html#service-side-context

@stanley-cheung
Copy link
Collaborator

This should be fixed by #847 and #858 in version 1.2.0. Now the callbacks behavior should align with the grpc-node implementations. A response with a non-OK status will be treated as an error. The response will not be returned to align with other grpc client implementations.

loyalpartner pushed a commit to loyalpartner/grpc-web that referenced this issue Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants