Native: fix generic Client constructor crashing

This commit is contained in:
murgatroid99 2019-03-20 16:26:05 -07:00
parent dca2016e5c
commit fe7b2e8214
2 changed files with 16 additions and 7 deletions

View File

@ -376,12 +376,14 @@ function Client(address, credentials, options) {
}
self.$interceptors = options.interceptors || [];
self.$interceptor_providers = options.interceptor_providers || [];
Object.keys(self.$method_definitions).forEach(method_name => {
const method_definition = self.$method_definitions[method_name];
self[method_name].interceptors = client_interceptors
.resolveInterceptorProviders(self.$interceptor_providers, method_definition)
.concat(self.$interceptors);
});
if (self.$method_definitions) {
Object.keys(self.$method_definitions).forEach(method_name => {
const method_definition = self.$method_definitions[method_name];
self[method_name].interceptors = client_interceptors
.resolveInterceptorProviders(self.$interceptor_providers, method_definition)
.concat(self.$interceptors);
});
}
this.$callInvocationTransformer = options.callInvocationTransformer;

View File

@ -220,6 +220,13 @@ describe('Client constructor building', function() {
assert.strictEqual(Client.prototype.add, Client.prototype.Add);
});
});
describe('Generic client', function() {
it('Should construct without error', function() {
assert.doesNotThrow(() => {
const client = new grpc.Client('localhost: 50051', grpc.credentials.createInsecure());
});
});
});
describe('waitForClientReady', function() {
var server;
var port;
@ -314,7 +321,7 @@ describe('Echo service', function() {
});
});
});
describe('Generic client and server', function() {
describe('Non-protobuf client and server', function() {
function toString(val) {
return val.toString();
}