denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
93.06k stars 5.14k forks source link

`npm:@grpc/grpc-js` support #23714

Open satyarohith opened 1 week ago

satyarohith commented 1 week ago

We're actively working to support https://www.npmjs.com/package/@grpc/grpc-js in Deno. This issue tracks the progress.

The following client examples work with deno canary:

You can test them by cloning https://github.com/satyarohith/grpc-node/tree/es_examples and running the server using node and client using deno. We will focus on server examples once we have all the client examples working.

TODO:

Related issues:

AlfieJones commented 1 week ago

It'd be awesome if we could get the static generation working too. ts-proto makes it pretty easy to generate the code with es modules & typescript.

I put together a fork of your fork with the typescript generated for the helloworld example: https://github.com/AlfieJones/grpc-node/tree/es_examples.

I used the following to generate the types:

protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=. ./examples/protos/helloworld.proto --ts_proto_opt=outputServices=grpc-js,importSuffix=.js

Currently, I'm getting the following error for that example: "Request message serialization failure: Cannot read properties of undefined (reading 'from')"

satyarohith commented 3 days ago

error_handling client example works with https://github.com/denoland/deno/pull/23755

➜  examples git:(main) denod run -A --unstable-byonm error_handling/client.js
[1] Calling SayHello with name:""
Warning: Not implemented: Http2Session.socket
[1] Received error 3 INVALID_ARGUMENT: request missing required field: name
[2] Calling SayHello with name:"sr"
Warning: Not implemented: Http2Session.socket
[2] Received response Hello sr
[3] Calling SayHelloStreamReply with name:""
Warning: Not implemented: Http2Session.socket
[3] Received expected error 3 INVALID_ARGUMENT: request missing required field: name
[3] Received status with code=INVALID_ARGUMENT details=request missing required field: name
[4] Calling SayHelloStreamReply with name:"sr"
Warning: Not implemented: Http2Session.socket
[4] Received response Hello sr
[4] Received response Hello sr
[4] Received response Hello sr
[4] Received response Hello sr
[4] Received response Hello sr
[4] Received status with code=OK details=OK