From e480a0a686a4ecf98d1f0ff348c6f1d0027e31f5 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 7 Oct 2019 13:44:08 -0700 Subject: [PATCH] grpc-js: pick first: remove reference and go idle after disconnect --- packages/grpc-js/package.json | 2 +- packages/grpc-js/src/load-balancer-pick-first.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/grpc-js/package.json b/packages/grpc-js/package.json index 38e10479..d80e4070 100644 --- a/packages/grpc-js/package.json +++ b/packages/grpc-js/package.json @@ -1,6 +1,6 @@ { "name": "@grpc/grpc-js", - "version": "0.6.5", + "version": "0.6.6", "description": "gRPC Library for Node - pure JS implementation", "homepage": "https://grpc.io/", "repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js", diff --git a/packages/grpc-js/src/load-balancer-pick-first.ts b/packages/grpc-js/src/load-balancer-pick-first.ts index a12fc8e2..5d221fc0 100644 --- a/packages/grpc-js/src/load-balancer-pick-first.ts +++ b/packages/grpc-js/src/load-balancer-pick-first.ts @@ -184,6 +184,7 @@ export class PickFirstLoadBalancer implements LoadBalancer { newState: ConnectivityState ) => { if (newState !== ConnectivityState.READY) { + this.currentPick = null; subchannel.unref(); subchannel.removeConnectivityStateListener( this.pickedSubchannelStateListener @@ -203,8 +204,11 @@ export class PickFirstLoadBalancer implements LoadBalancer { this.updateState(newLBState, new QueuePicker(this)); } } else { - this.connectToAddressList(); - this.channelControlHelper.requestReresolution(); + /* We don't need to backoff here because this only happens if a + * subchannel successfully connects then disconnects, so it will not + * create a loop of attempting to connect to an unreachable backend + */ + this.updateState(ConnectivityState.IDLE, new QueuePicker(this)); } } }; @@ -348,6 +352,7 @@ export class PickFirstLoadBalancer implements LoadBalancer { subchannel.startConnecting(); } if (this.currentState === ConnectivityState.IDLE) { + this.channelControlHelper.requestReresolution(); if (this.latestAddressList.length > 0) { this.connectToAddressList(); }