From 887d2ef677e66a0a1a6e6cca1faa6467ad252e96 Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Tue, 2 Feb 2021 14:16:10 -0800 Subject: [PATCH] Kick the ResolvingLoadBalancer out of IDLE when the first call is started. --- packages/grpc-js/src/channel.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/grpc-js/src/channel.ts b/packages/grpc-js/src/channel.ts index 7c61aa1f..fd015aff 100644 --- a/packages/grpc-js/src/channel.ts +++ b/packages/grpc-js/src/channel.ts @@ -261,6 +261,7 @@ export class ChannelImplementation implements Channel { for (const {callStream, callMetadata} of this.configSelectionQueue) { this.tryGetConfig(callStream, callMetadata); } + this.configSelectionQueue = []; }); } ); @@ -474,6 +475,11 @@ export class ChannelImplementation implements Channel { private tryGetConfig(stream: Http2CallStream, metadata: Metadata) { if (this.configSelector === null) { + /* This branch will only be taken at the beginning of the channel's life, + * before the resolver ever returns a result. So, the + * ResolvingLoadBalancer may be idle and if so it needs to be kicked + * because it now has a pending request. */ + this.resolvingLoadBalancer.exitIdle(); this.callRefTimer.ref?.(); this.configSelectionQueue.push({ callStream: stream,