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

Support client streaming in grpc-web #329

Closed
doctorpangloss opened this issue Jun 27, 2021 · 5 comments
Closed

Support client streaming in grpc-web #329

doctorpangloss opened this issue Jun 27, 2021 · 5 comments

Comments

@doctorpangloss
Copy link

I don't know why it's being emitted regardless of how I configure ts-proto.

Source example:

service A {
  rpc B(stream google.proto.Empty) returns (stream google.proto.Empty) {}
}

will generate

B(
      request: DeepPartial<Observable<Empty>>,
      metadata?: grpc.Metadata,
    ): Observable<HostReply> {
      return this.rpc.invoke(
        RemoteBDesc,
        Observable<Empty>.fromPartial(request),
        metadata,
      );
    }

version: 1.81.3
options:

        option "outputClientImpl=grpc-web"
        option "esModuleInterop=true"
        option "returnObservable=false"
        option "addGrpcMetadata=true"
        option "forceLong=number"
        option "oneof=unions"
        option "outputJsonMethods=false"
        option "lowerCaseServiceMethods=true"
@stephenh
Copy link
Owner

Yeah, hm, it looks like this line:

https://github.com/stephenh/ts-proto/blob/main/src/generate-grpc-web.ts#L65

Was written before/without realizing that this line:

https://github.com/stephenh/ts-proto/blob/main/src/types.ts#L540

Might return Observable, because streaming support was added later, and for a specific use case instead across the board for all combinations of options (as you're finding).

If you could reproduce in one of the integration/... directories that covers the grpc-web output, and submit a PR/fix, that'd be great. Thanks!

@stephenh stephenh changed the title Observable<?>.fromPartial appearing in source code, no known type Support client streaming in grpc-web Jul 15, 2021
@stephenh
Copy link
Owner

Updating my prior diagnosis, this doesn't come from "we shouldn't use Observable here, it's that methods that are clientStreaming basically have to use Observable (to present the client is sending 0 or N messages, and so we need Observable to tell us when the last N-th message has been written by the client) and ts-proto doesn't have Observable / grpc-web wiring built yet.

@snyh
Copy link

snyh commented Jul 15, 2022

The PR #617 is seems trying to support client stream for grpc-web

@stephenh
Copy link
Owner

This is fixed in #617 , thanks @luhuaei !

@luhuaei
Copy link
Contributor

luhuaei commented Jul 30, 2022

Try to support (client/server) streaming not Observable type. #633

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

4 participants