Skip to content

Commit 2767660

Browse files
authored
Merge pull request #1920 from murgatroid99/grpc-js-xds_handle_ok_status
grpc-js-xds: Handle all ways control-plane streams can end
2 parents 6cea491 + cb6abd7 commit 2767660

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

packages/grpc-js-xds/src/xds-client.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -516,13 +516,15 @@ export class XdsClient {
516516
}
517517
}
518518

519-
private handleAdsCallError(error: ServiceError) {
519+
private handleAdsCallStatus(streamStatus: StatusObject) {
520520
trace(
521-
'ADS stream ended. code=' + error.code + ' details= ' + error.details
521+
'ADS stream ended. code=' + streamStatus.code + ' details= ' + streamStatus.details
522522
);
523523
this.adsCallV2 = null;
524524
this.adsCallV3 = null;
525-
this.reportStreamError(error);
525+
if (streamStatus.code !== status.OK) {
526+
this.reportStreamError(streamStatus);
527+
}
526528
/* If the backoff timer is no longer running, we do not need to wait any
527529
* more to start the new call. */
528530
if (!this.adsBackoff.isRunning()) {
@@ -544,9 +546,10 @@ export class XdsClient {
544546
this.adsCallV2.on('data', (message: DiscoveryResponse__Output) => {
545547
this.handleAdsResponse(message);
546548
});
547-
this.adsCallV2.on('error', (error: ServiceError) => {
548-
this.handleAdsCallError(error);
549+
this.adsCallV2.on('status', (status: StatusObject) => {
550+
this.handleAdsCallStatus(status);
549551
});
552+
this.adsCallV2.on('error', () => {});
550553
return true;
551554
}
552555

@@ -564,9 +567,10 @@ export class XdsClient {
564567
this.adsCallV3.on('data', (message: DiscoveryResponse__Output) => {
565568
this.handleAdsResponse(message);
566569
});
567-
this.adsCallV3.on('error', (error: ServiceError) => {
568-
this.handleAdsCallError(error);
570+
this.adsCallV3.on('status', (status: StatusObject) => {
571+
this.handleAdsCallStatus(status);
569572
});
573+
this.adsCallV3.on('error', () => {});
570574
return true;
571575
}
572576

@@ -772,9 +776,9 @@ export class XdsClient {
772776
this.receivedLrsSettingsForCurrentStream = true;
773777
}
774778

775-
private handleLrsCallError(error: ServiceError) {
779+
private handleLrsCallStatus(streamStatus: StatusObject) {
776780
trace(
777-
'LRS stream ended. code=' + error.code + ' details= ' + error.details
781+
'LRS stream ended. code=' + streamStatus.code + ' details= ' + streamStatus.details
778782
);
779783
this.lrsCallV2 = null;
780784
this.lrsCallV3 = null;
@@ -798,9 +802,10 @@ export class XdsClient {
798802
this.lrsCallV2.on('data', (message: LoadStatsResponse__Output) => {
799803
this.handleLrsResponse(message);
800804
});
801-
this.lrsCallV2.on('error', (error: ServiceError) => {
802-
this.handleLrsCallError(error);
805+
this.lrsCallV2.on('status', (status: StatusObject) => {
806+
this.handleLrsCallStatus(status);
803807
});
808+
this.lrsCallV2.on('error', () => {});
804809
return true;
805810
}
806811

@@ -816,9 +821,10 @@ export class XdsClient {
816821
this.lrsCallV3.on('data', (message: LoadStatsResponse__Output) => {
817822
this.handleLrsResponse(message);
818823
});
819-
this.lrsCallV3.on('error', (error: ServiceError) => {
820-
this.handleLrsCallError(error);
824+
this.lrsCallV3.on('status', (status: StatusObject) => {
825+
this.handleLrsCallStatus(status);
821826
});
827+
this.lrsCallV3.on('error', () => {});
822828
return true;
823829
}
824830

0 commit comments

Comments
 (0)