mirror of https://github.com/grpc/grpc-node.git
Merge pull request #2380 from murgatroid99/grpc-js_pick_first_fix2
grpc-js: Fix address equality check in pick-first
This commit is contained in:
commit
7aba0004e6
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@grpc/grpc-js",
|
"name": "@grpc/grpc-js",
|
||||||
"version": "1.8.11",
|
"version": "1.8.12",
|
||||||
"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",
|
||||||
|
|
|
@ -420,8 +420,9 @@ export class PickFirstLoadBalancer implements LoadBalancer {
|
||||||
* address list is different from the existing one */
|
* address list is different from the existing one */
|
||||||
if (
|
if (
|
||||||
this.subchannels.length === 0 ||
|
this.subchannels.length === 0 ||
|
||||||
|
this.latestAddressList.length !== addressList.length ||
|
||||||
!this.latestAddressList.every(
|
!this.latestAddressList.every(
|
||||||
(value, index) => subchannelAddressEqual(addressList[index], value)
|
(value, index) => addressList[index] && subchannelAddressEqual(addressList[index], value)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
this.latestAddressList = addressList;
|
this.latestAddressList = addressList;
|
||||||
|
|
|
@ -41,9 +41,15 @@ export function isTcpSubchannelAddress(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function subchannelAddressEqual(
|
export function subchannelAddressEqual(
|
||||||
address1: SubchannelAddress,
|
address1?: SubchannelAddress,
|
||||||
address2: SubchannelAddress
|
address2?: SubchannelAddress
|
||||||
): boolean {
|
): boolean {
|
||||||
|
if (!address1 && !address2) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!address1 || !address2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (isTcpSubchannelAddress(address1)) {
|
if (isTcpSubchannelAddress(address1)) {
|
||||||
return (
|
return (
|
||||||
isTcpSubchannelAddress(address2) &&
|
isTcpSubchannelAddress(address2) &&
|
||||||
|
|
Loading…
Reference in New Issue