Hi,

I have a service Foo defined like so:

syntax = "proto3";

import "google/protobuf/empty.proto";

service Foo {
  rpc Ping(google.protobuf.Empty) returns (Pong);
}

message Pong {
  bool alive = 1;
}

from which I codegen the JavaScript files I need to implement a client like 
this:

const google_protobuf_empty_pb = 
require('google-protobuf/google/protobuf/empty_pb.js');
const {SubscribeRequest,Offset} = require('./foo_pb.js');
const {ProxyClient} = require('./foo_grpc_web_pb.js');

var client = new FooClient('http://' + window.location.hostname + ':9000', 
null, null);

client.ping(google_protobuf_empty_pb, {}, (err, resp) => {
  console.log(resp);
});

I then `npx webpack` this script to build a `./dist/main.js` served from 
`index.html`.

My problem though is that the Ping RPC in my main.js does not resolve the 
type of the `request` correctly which results in:

Uncaught TypeError: e.serializeBinary is not a function
    at 
module$contents$grpc$web$AbstractClientBase_AbstractClientBase.MethodInfo.requestSerializeFn
 
(main.js:8)
    at module$contents$grpc$web$GrpcWebClientBase_GrpcWebClientBase.rpcCall 
(main.js:8)
    at n.FooClient.ping (main.js:8)
    at Object.<anonymous> (main.js:1)
    at o (main.js:1)
    at main.js:1
    at main.js:1
(anonymous) @ main.js:8
module$contents$grpc$web$GrpcWebClientBase_GrpcWebClientBase.rpcCall @ 
main.js:8
n.FooClient.ping @ main.js:8
(anonymous) @ main.js:1
o @ main.js:1
(anonymous) @ main.js:1
(anonymous) @ main.js:1

How do I use the google.protobuf.Empty type properly when making requests 
using grpc-web?

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/0dd7958e-fcd4-4420-9a66-3d608f9423b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to