From 22521ef8a7dd91db10c63e2c1f49624be78a3d4c Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Tue, 24 Mar 2020 11:12:40 -0700 Subject: [PATCH] Fix options type check --- packages/grpc-js/src/channel.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/grpc-js/src/channel.ts b/packages/grpc-js/src/channel.ts index cdbc81a2..9f570c0f 100644 --- a/packages/grpc-js/src/channel.ts +++ b/packages/grpc-js/src/channel.ts @@ -146,8 +146,10 @@ export class ChannelImplementation implements Channel { if (!(credentials instanceof ChannelCredentials)) { throw new TypeError('Channel credentials must be a ChannelCredentials object'); } - if ((typeof options !== 'object') || !Object.values(options).every(value => typeof value === 'string' || typeof value === 'number')) { - throw new TypeError('Channel options must be an object with string or number values'); + if (options) { + if ((typeof options !== 'object') || !Object.values(options).every(value => typeof value === 'string' || typeof value === 'number')) { + throw new TypeError('Channel options must be an object with string or number values'); + } } /* The global boolean parameter to getSubchannelPool has the inverse meaning to what * the grpc.use_local_subchannel_pool channel option means. */