-
Notifications
You must be signed in to change notification settings - Fork 348
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
fix: grpc-web issue#239 where client streaming was producing incorr… #335
base: main
Are you sure you want to change the base?
Conversation
@@ -539,7 +539,8 @@ export function detectMapType( | |||
|
|||
export function requestType(ctx: Context, methodDesc: MethodDescriptorProto): Code { | |||
let typeName = messageToTypeName(ctx, methodDesc.inputType); | |||
if (methodDesc.clientStreaming) { | |||
const { options } = ctx; | |||
if (options.nestJs && methodDesc.clientStreaming) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this fixes the compile error, but in a pretty indirect way, right? Like the *.proto
file is saying "the client can submit a stream of messages" and this is basically saying "we won't do that"...which, compiles, but does it actually work?
Like looking at the grpc-web examples, if a method is stream Cred
we can't just write a Cred
and call it good, we need to tell the server "we could have sent more Cred
s but we're not", i.e. by calling finishSend
:
https://github.com/improbable-eng/grpc-web/blob/master/client/grpc-web/src/client.ts#L304
So this is less of "just fix the compile error" and more that I think we need to actually support client-to-server / request streaming. Until then, ts-proto just won't work with *.proto
files that use stream Cred
.
Maybe we could like skip putting those methods in the output until it's supported, so that if you have a *.proto
file that has those, but you don't need to call them, you'd at least get output that would let you use the other methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right, this does just fix the compile error. I don't have rpc services with a backend setup right now to test; though; from what improbable says , it's not supported. + cheers for the pointer re finishSend
Omitting entirely the stream Cred
methods sounds like a good plan; stay tuned
Fwiw @samelie I pushed a "re-codegen" commit to this PR that undoes a lot of |
Hey @stephenh hopefully this approach is better. the goal of not generating Also, off topic, any thoughts on bumping |
Hi @samelie Is this PR still under development? |
I'm really not familiar with client streaming in grpc-web. I saw a post on their issues about it saying you needed the websocket transport. Makes sense. For me, this wouldn't be an issue (am fine with it not working), however I'm in a work situation where we need to run
The easiest solution in the vein of here be dragons is just to treat clientSide in the case of grpc-web && !nestJs like a normal Promise rpc I'd be happy to propose my forked fix for this that changes
Less magical solutions would be better. Perhaps some ctx option to ignore all clientStreaming? |
cdf2835
to
7017d4c
Compare
fixing grpc-web issue#239 where client streaming was producing incorect requestType
Based on this issue #329
Hopefully this fix isn't overly naive
Thanks for all the hardwork putting this together; it's really cool