Skip to content

Commit

Permalink
fix: set default values for gRPC parameters (#840)
Browse files Browse the repository at this point in the history
* set grpc default value

* test

* test

* test 1000ms

* test 1000ms

* clean up
  • Loading branch information
xiaozhenliu-gg5 authored Jun 3, 2020
1 parent c401b80 commit f7ebfb6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,12 @@ export class GrpcClient {
const serviceAddress = options.servicePath + ':' + options.port;
const creds = await this._getCredentials(options);
const grpcOptions: ClientOptions = {};
// @grpc/grpc-js limits max receive message length starting from v0.8.0
// @grpc/grpc-js limits max receive/send message length starting from v0.8.0
// https://github.com/grpc/grpc-node/releases/tag/%40grpc%2Fgrpc-js%400.8.0
// To keep the existing behavior and avoid libraries breakage, we pass -1 there as suggested.
grpcOptions['grpc.max_receive_message_length'] = -1;
grpcOptions['grpc.max_send_message_length'] = -1;
grpcOptions['grpc.initial_reconnect_backoff_ms'] = 1000;
Object.keys(options).forEach(key => {
const value = options[key];
// the older versions had a bug which required users to call an option
Expand Down
2 changes: 2 additions & 0 deletions test/unit/grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ describe('grpc', () => {
assert.deepStrictEqual(stub.creds, dummyChannelCreds);
assert.deepStrictEqual(stub.options, {
'grpc.max_receive_message_length': -1,
'grpc.max_send_message_length': -1,
'grpc.initial_reconnect_backoff_ms': 1000,
});
});
});
Expand Down

0 comments on commit f7ebfb6

Please sign in to comment.