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:
Michael Lumish 2023-03-07 14:24:14 -08:00 committed by GitHub
commit 7aba0004e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

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

View File

@ -420,8 +420,9 @@ export class PickFirstLoadBalancer implements LoadBalancer {
* address list is different from the existing one */
if (
this.subchannels.length === 0 ||
this.latestAddressList.length !== addressList.length ||
!this.latestAddressList.every(
(value, index) => subchannelAddressEqual(addressList[index], value)
(value, index) => addressList[index] && subchannelAddressEqual(addressList[index], value)
)
) {
this.latestAddressList = addressList;

View File

@ -41,9 +41,15 @@ export function isTcpSubchannelAddress(
}
export function subchannelAddressEqual(
address1: SubchannelAddress,
address2: SubchannelAddress
address1?: SubchannelAddress,
address2?: SubchannelAddress
): boolean {
if (!address1 && !address2) {
return true;
}
if (!address1 || !address2) {
return false;
}
if (isTcpSubchannelAddress(address1)) {
return (
isTcpSubchannelAddress(address2) &&