grpc / grpc-web

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

Response deserialize error #991

Closed JuliusKoronci closed 3 years ago

JuliusKoronci commented 3 years ago

Hi, We are trying to use streams with a net core backend but getting deserialize error

    "method":string"###"
    "error":{2 items
    "code":int2
    "message":string"Error in response deserializer function."
  }
}

protoc is version 3.14.0 grpc-web-gen is 1.2.1

command to generate the client is: protoc -I=./protos ./protos/*.proto --js_out=import_style=commonjs,binary:./dist --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:./dist

We successfully connect to the endpoint and retrieve the data and the call fails on tying to use response.getMessage() Since there is no other error message and debugging is not very straightforward any insight on what could cause this error would be welcome :)

thank you

povesteam commented 3 years ago

@JuliusKoronci Did you find out why the error was occurring?

I am having the same error via grpc-web, but calling the same method with the same parameters via grpcurl, it works.

image

JuliusKoronci commented 3 years ago

@povesteam the issue is a mismatch between the contracts and the returned data..but since it fails even before the data can be inspected it is impossible to debug. Since the tooling is not mature enough we dropped grpc-web as we run into this issue again and we cant afford to spend days on debugging :)

Poafs1 commented 3 years ago

@JuliusKoronci I got the same issue. Downgrade the Protoc compiler to the release version before the latest of the grpc-web can solves your problem.

CoachRDeveloper commented 3 years ago

Stopping the development server and calling npm start again (recompile js) solved the issue.

nadilas commented 3 years ago

@JuliusKoronci @CoachRDeveloper I am having the same issue with one specific method, all others work fine. Recompiling doesn't help. How did you get rid of the error?

protoc is version 3.14.0 grpc-web-gen is 1.2.1

robcecil commented 3 years ago

@JuliusKoronci I got the same issue. Downgrade the Protoc compiler to the release version before the latest of the grpc-web can solves your problem.

This fixed the issue for me. Downgraded to 3.13.0, which was released before protoc-gen-grpc 1.2.1

ghost commented 3 years ago

I got the same error with gRPC Web because I copied the example without realizing getMessage() was not part of the framework API, but a message string field in the example Protobuf definition.

Try using response directly (or serializing it with toObject())

var stream = echoService.serverStreamingEcho(streamRequest, metadata);
stream.on('data', function(response) {
  console.log(response.toObject());
});
pontovinte commented 3 years ago

I got the same error with gRPC Web because I copied the example without realizing getMessage() was not part of the framework API, but a message string field in the example Protobuf definition.

Try using response directly (or serializing it with toObject())

var stream = echoService.serverStreamingEcho(streamRequest, metadata);
stream.on('data', function(response) {
  console.log(response.toObject());
});

This worked for me!