grpc / grpc/grpc-node

[NodeJS] Promises and async/await

Open
#54 45 comments 216 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.8k
Forks
716
Avg merge
2d 3h
Merged PRs (30d)
10

Description

It would be nice if there was a `grpc-tools` and/or `grpc_node_plugin` option that would generate client and server code that follows the ES6 Promise and ES7 async/await model.

For example, instead of:
https://github.com/grpc/grpc/blob/98f8989a6712118549c432c9f91b6a516250014d/examples/node/static_codegen/greeter_client.js#L35-L37
We could write:
```
[err, response] = await client.sayHello(request);
```
Or something similar. On the server side, instead of:
https://github.com/grpc/grpc/blob/98f8989a6712118549c432c9f91b6a516250014d/examples/node/static_codegen/greeter_server.js#L27-L31
We could write:
```
async function sayHello(call) {
var reply = new messages.HelloReply();
reply.setMessage('Hello ' + call.request.getName());
return [null, reply]
}
```
Again, just ideas.

This feature would eliminate the need for wrapper code for users wanting to use this pattern. I would love to know if anyone is interested in this feature or planning on adding it. Thanks!

(moved from https://github.com/grpc/grpc/issues/12751)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.