grpc / grpc/grpc-node

Usage of custom options

Open
#1,772 10 comments 1 reaction 0 assignees View on GitHub
package: @grpc/proto-loader
Dominant language
TypeScript
Stars
4.8k
Forks
716
Avg merge
2d 3h
Merged PRs (30d)
10

Description

### Problem description
How do I get defined custom options from messages and services? The messages and service objects from output has `options` properties, but it is always null.

### Reproduction steps
1. Run `npm init -y` in a new directory
2. Run `npm install @grpc/proto-loader@0.6.1`
3. **main.js**
```javascript
const proto = require('@grpc/proto-loader')
const util = require('util')

const definition = proto.loadSync('main.proto')
console.log('MyService: ', util.inspect(definition.MyService, false, 1000, true))
console.log('MyMessage: ', util.inspect(definition.MyMessage, false, 1000, true))
```
4. **main.proto**
```proto
syntax = "proto3";
import "google/protobuf/descriptor.proto";

extend google.protobuf.MessageOptions {
string my_option = 51234;
}

service MyService {
rpc MyRpc(MyMessage) returns (MyMessage) {
option (my_option) = "Hello world!";
}
}

message MyMessage {
option (my_option) = "Hello world!";
}
```
5. Run `node main.js`
6. The output doesn't contain any info about custom options.

### Environment
- OS name, version and architecture: [Windows 10 64x 20H2]
- Node version [v14.16.1]
- Node installation method [website]
- If applicable, compiler version []
- Package name and version [@grpc/proto-loader@0.6.1]

### Additional context

`@grpc/grpc-js` does not add any additional data about custom options.

Console output: https://gist.githubusercontent.com/tscpp/32f889a1989b8f86e6a91af507438b53/raw/6973cab8d80dafcd2a94eff3ace1305ae133fd86/log.txt

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.