grpc-js: pick-first: fix bad state transition when reconnecting connected LB

This commit is contained in:
murgatroid99 2019-10-08 16:35:42 -07:00
parent af5589be5a
commit ee72cd440f
2 changed files with 10 additions and 10 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@grpc/grpc-js", "name": "@grpc/grpc-js",
"version": "0.6.6", "version": "0.6.7",
"description": "gRPC Library for Node - pure JS implementation", "description": "gRPC Library for Node - pure JS implementation",
"homepage": "https://grpc.io/", "homepage": "https://grpc.io/",
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js", "repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",

View File

@ -312,10 +312,6 @@ export class PickFirstLoadBalancer implements LoadBalancer {
subchannel.addConnectivityStateListener(this.subchannelStateListener); subchannel.addConnectivityStateListener(this.subchannelStateListener);
if (subchannel.getConnectivityState() === ConnectivityState.READY) { if (subchannel.getConnectivityState() === ConnectivityState.READY) {
this.pickSubchannel(subchannel); this.pickSubchannel(subchannel);
this.updateState(
ConnectivityState.READY,
new PickFirstPicker(subchannel)
);
this.resetSubchannelList(); this.resetSubchannelList();
return; return;
} }
@ -327,15 +323,19 @@ export class PickFirstLoadBalancer implements LoadBalancer {
subchannelState === ConnectivityState.CONNECTING subchannelState === ConnectivityState.CONNECTING
) { ) {
this.startConnecting(index); this.startConnecting(index);
this.updateState(ConnectivityState.CONNECTING, new QueuePicker(this)); if (this.currentPick === null) {
this.updateState(ConnectivityState.CONNECTING, new QueuePicker(this));
}
return; return;
} }
} }
// If the code reaches this point, every subchannel must be in TRANSIENT_FAILURE // If the code reaches this point, every subchannel must be in TRANSIENT_FAILURE
this.updateState( if (this.currentPick === null) {
ConnectivityState.TRANSIENT_FAILURE, this.updateState(
new UnavailablePicker() ConnectivityState.TRANSIENT_FAILURE,
); new UnavailablePicker()
);
}
} }
updateAddressList( updateAddressList(