-
Notifications
You must be signed in to change notification settings - Fork 764
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
Last update (v1.2.0) broke promise based unary call #865
Comments
Can you give us a bit more information on how it broke? Which #746 was included in the There are some tests for the Promise-based unary calls here: https://github.com/grpc/grpc-web/blob/master/packages/grpc-web/test/plugin_test.js#L241. Not a lot but should cover some basic cases. Perhaps you are using a different mode? |
We have I guess a connected issue at https://github.com/ngx-grpc/ngx-grpc const stream = this.client.rpcCall(
this.settings.host + path,
req,
metadata || {},
new AbstractClientBase.MethodInfo(
resclss,
(request: Q) => reqclss.toBinary(request),
resclss.fromBinary
),
() => null
);
stream.on('data', data => obs.next(new GrpcDataEvent(data))); // <= the data event is not triggered anymore The problem occurs only for unary calls. Server streaming works fine. @stanley-cheung shoud the data event be emitted on unary calls? P.s.: v1.1.0 still emits data event. |
@smnbbrv This is intentional. In the This is also an effort to align the behavior to be consistent with grpc-node. For unary calls, you should not be receiving response via the In #858, there's a table summarizing whether each callback will be triggered in different scenarios. Please check that out. Also, I noticed that you are not using the generated code surface and are calling directly into the generic layer. There you might want to be careful as that's not the general supported API surface and we may be changing this layer in the future. In fact, I noticed that you are still using the |
@stanley-cheung thank you very much for the detailed answer!
This is exactly the error I had before, and this was the reason why I chose the event "way", to be more similar to the streaming syntax. However, now I simply switch to the proper way of handling the unary response.
I know that using the underlying methods is dangerous, however, there was no other option (at the implementation time) to get it working. Also, the risk is accepted and I tried to prepare to those breaking changes by generalising the client implementation as much as it is possible; so, ideally it should survive breaking changes. I will learn the changes and will come back in case of problems :) Thank you again for your time and help. |
@stanley-cheung whoops, the TypeScript definitions do not have the With bypassing the typings declare var require;
console.log(require('grpc-web').MethodDescriptor); I can read it in TypeScript. Looks like grpc-web's TypeScript mode still uses |
Ah I see. Yea then that's a separate issue we need to fix then. Thanks for pointing that out. |
@stanley-cheung should I create the issue? There is another notable difference (maybe actually it was the same before, but with events it worked differently). The event with status code OK comes before the unary callback is called, while all streaming callbacks land before the OK-code event. This is the timeline for unary request: And this is the timeline for server stream: Is this intended? To my taste it is a little bit weird. Do I miss something? |
In the streaming case, that will be the case. The For unary calls, there is no guarantee. You should not rely on the sequence of those events. |
@Fl0pZz just want to check in to see if you still have issue with the |
@stanley-cheung ok, close this issue. Thanks! |
Thanks! |
#746
And this file does not have any test for thus:
https://github.com/grpc/grpc-web/blob/master/packages/grpc-web/test/generated_code_test.js
The text was updated successfully, but these errors were encountered: