-
Notifications
You must be signed in to change notification settings - Fork 647
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
Error sent from streaming method not being returned #287
Comments
I don't recognize that API. Is that code using the Node gRPC library? How is grpc-web involved? Whatever the answer is, that error is almost definitely being output by some kind of asynchronous operation. A |
Sorry I wasn't clear, that code is inside of a method handler. Don't worry about the grpc-web detail, that's just the client. The https://grpc.io/grpc/node/grpc-ServerWritableStream.html And in my debugging, I can see that the error is definitely being sent to the destroy() method directly. Here's a simplified handler function that I just tested in my app to ensure the error isn't making it to the client.
(that gets passed to Alternatively for example, a unary API error response works fine:
|
OK, that's interesting. I didn't know about the |
@murgatroid99 Are you aware of an alternative method to send an error from a streaming API? |
In our tests, we just do |
Aha, that works perfectly. It would be nice if there was a way to send an error message though. Would it be welcome if I submitted a PR to the tutorial file with an example? https://grpc.io/docs/tutorials/basic/node.html |
Are you having problems sending the error message? I think that code would do it. If it isn't working, you may want to try calling the string As for the tutorial, that's a bit complicated because we generally prefer to keep our examples aligned across languages, and I don't know if there is currently a plan for cross language error handling examples. There is this repository with some gRPC error examples, so you may want to ask there about adding examples for streaming calls. |
@murgatroid99 I'll check out that repo, thank you. It seems that the issue was in part caused by an extra call.end() in my code that was closing the connection before the response could be sent. Thanks! |
My method handler code looks something like this:
The upload() method throws an object that looks like this:
But that error is never making it back to the client. The response is completely empty. Is this the wrong way to pass an error to the client from a streaming API? Perhaps an important detail is that I'm using the Improbable GRPC-Web proxy, I suppose it's possible that the error isn't making it through the proxy. I want to make sure I'm doing this part correctly though, as none of the docs I've seen mention how to throw errors from a server-streaming API.
The text was updated successfully, but these errors were encountered: