grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.56k stars 762 forks source link

Remove outdated limitation regarding format mode #1191

Closed trysetnull closed 2 years ago

trysetnull commented 2 years ago

The README states that "only unary calls are supported for now" regarding the mode=grpcweb (binary protobuf format). I have a server streaming call and am generating typescript code with the following, it seems to work.

protoc \
    --proto_path=./ \
    --plugin=protoc-gen-grpc-web=/usr/local/grpc-web/protoc-gen-grpc-web \
    --js_out=import_style=commonjs,binary:${OUT_DIR} \
    --grpc-web_out=import_style=typescript,mode=grpcweb:${OUT_DIR} \
    ${INPUT_FILE}

Also it seems this is tested: scripts/docker-run-interop-tests.sh

Am I missing something?

linux-foundation-easycla[bot] commented 2 years ago

CLA Signed

The committers are authorized under a signed CLA.

sampajano commented 2 years ago

Hi! thanks so much for your PR!

Unfortunately, server streaming should STILL NOT be working for the binary mode...

The reason is that XHR streaming (which we're using) only works for text-based responses (see some references here).

I have a server streaming call and am generating typescript code with the following, it seems to work.

When server streaming is working, the responses should come in chunks. In binary mode, all of the response chunks will come back all at once at the end of the stream. Is that maybe the behavior that you're seeing?

Also it seems this is tested: scripts/docker-run-interop-tests.sh

Yes, binary mode is indeed tested in the interop-test! Although, server streaming was specifically disabled for binary mode testing (here).. 😃

(FYI I actually tried this and it was working for me for a while.. I was super confused and then it turned out that my browser was caching the main.js from a previous session.. 😂 I'll sent a PR to disable the caching so this shouldn't confuse anymore.. Just want to mention in case this was your problem too..)

I will close the PR now. But further discussions here will be welcome! :)