grpc / grpc-web

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

Protoc is unable to generate grpc-web_out files #1288

Closed ak-em1603 closed 1 year ago

ak-em1603 commented 1 year ago

I am trying to generate codegen files for javascript using following command inside a docker image:- protoc -I=proto_dir ee.proto --js_out=import_style=commonjs:proto_gen_dir/js --grpc-web_out=import_style=commonjs,mode=grpcwebtext:proto_gen_dir/js

It only generates "ee_pb.js" file and does not generate "ee_grpc_web_pb.js" file. The command does not throw any error.

The protoc is installed using following command. The version 3.20.1 is used due to some issue in generating js-out files:

RUN curl -sLO https://github.com/protocolbuffers/protobuf/releases/download/v3.20.1/protoc-3.20.1-linux-x86_64.zip
RUN unzip protoc-3.20.1-linux-x86_64.zip -d  /usr/local/bin/.proto_compiler
ENV PATH="$PATH:/usr/local/bin/.proto_compiler/bin"

The proto-gen-grpc-web plugin is installed using following commands:-

RUN curl -sLO https://github.com/grpc/grpc-web/releases/download/1.3.1/protoc-gen-grpc-web-1.3.1-linux-x86_64
RUN mv protoc-gen-grpc-web-1.3.1-linux-x86_64 /usr/local/bin/protoc-gen-grpc-web
RUN chmod +x /usr/local/bin/protoc-gen-grpc-web

proto-gen-grpc-web is on the PATH.

can anyone let me know as to what is the issue here?

sampajano commented 1 year ago

Aha that's interesting..

I wonder what's the output if you run the following command?

echo 'test' | protoc-gen-grpc-web

Expected output:

protoc-gen-grpc-web: protoc sent unparseable request to plugin.
ak-em1603 commented 1 year ago

I get the same output as mentioned by you.

Screenshot 2022-10-01 at 7 29 17 AM
ak-em1603 commented 1 year ago

Just to add more on this. I have tried the setup on three differnt platform :- Mac M1, Docker and Ubuntu. The behaviour is consistent for all three setup. The "ee_grpc_web_pb.js" file is not being generated.

ak-em1603 commented 1 year ago

Any updates?

sampajano commented 1 year ago

Hey sorry for delay.

To help narrow down the issue (between local env issue or with your specific proto files), could you try following the hello world example codegen commands and see if they work for you?

http://google3/javascript/net/grpc/web/streambodyclientreadablestream.js;l=326;rcl=478391678

thanks 😃


And if it is specific to your proto file, could you provide the content and directory structure of your files? Thanks!

ak-em1603 commented 1 year ago

This was a silly mistake on my part. The proto file definition had no service defined hence the gprc_web_out files were not generated. Closing this issue

sampajano commented 1 year ago

Aha no worries. glad it's working now :)