Closed
Description
Problem description
No support custom grpc error status code in @grpc/grpc-js package different with grpc(c core)
When My Golang server respone a custom grpc error status code, @grpc/grpc-js only get code 2 Unknow.
Reproduction steps
https://github.com/BobDu/grpc-errors-demo
see this code repository. The focus is on the commits after my fork.
I define a Custom Error Status enum in proto.
hello.proto
// my custom grpc error code
enum ErrorCode {
OK = 0;
CUSTOM_ERROR = 88;
}
In golang service. throw a grpc err with custom status.
go/server.go
func (s *HelloServer) SayHelloCustomErr(ctx context.Context, req *api.HelloReq) (*api.HelloResp, error) {
return nil, status.Errorf(codes.Code(api.ErrorCode_CUSTOM_ERROR.Number()), api.ErrorCode_CUSTOM_ERROR.String())
}
when i call this service use grpcurl. get it.
$ grpcurl -vv -plaintext -d '{"Name": "sssssssssssssssssss"}' --proto hello.proto 127.0.0.1:50051 hello.HelloService/SayHelloCustomErr
Resolved method descriptor:
rpc SayHelloCustomErr ( .hello.HelloReq ) returns ( .hello.HelloResp );
Request metadata to send:
(empty)
Response headers received:
(empty)
Response trailers received:
content-type: application/grpc
Sent 1 request and received 0 responses
ERROR:
Code: Code(88)
Message: CUSTOM_ERROR
when i use grpc (c core) client. The error code is 88 as expected.
$ node node/client.js
(node:18075) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
88 undefined: CUSTOM_ERROR
88
But, when i use @grpc/grpc-js client ,the result is 2 Unkonw.
$ node node2/client.js
2 UNKNOWN: CUSTOM_ERROR
2
Environment
in my demo code repository config file.
Additional context
N/A
thanks.