Merge pull request #799 from murgatroid99/native_generic_client_fix

Native: fix generic Client constructor crashing
This commit is contained in:
Michael Lumish 2019-03-25 17:10:59 -07:00 committed by GitHub
commit 1addf78d49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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();
}