grpc-js-xds: Handle all ways control-plane streams can end

This commit is contained in:
Michael Lumish 2021-09-30 11:50:37 -07:00
parent 5adea403ca
commit 19206e6d9f
1 changed files with 10 additions and 5 deletions

View File

@ -459,18 +459,22 @@ export class XdsClient {
this.adsCall.on('data', (message: DiscoveryResponse__Output) => {
this.handleAdsResponse(message);
});
this.adsCall.on('error', (error: ServiceError) => {
this.adsCall.on('status', (streamStatus: StatusObject) => {
trace(
'ADS stream ended. code=' + error.code + ' details= ' + error.details
'ADS stream ended. code=' + streamStatus.code + ' details= ' + streamStatus.details
);
this.adsCall = null;
this.reportStreamError(error);
if (streamStatus.code !== status.OK) {
this.reportStreamError(streamStatus);
}
/* If the backoff timer is no longer running, we do not need to wait any
* more to start the new call. */
if (!this.adsBackoff.isRunning()) {
this.maybeStartAdsStream();
}
});
this.adsCall.on('error', () => {});
const allTypeUrls: AdsTypeUrl[] = [
EDS_TYPE_URL,
@ -611,9 +615,9 @@ export class XdsClient {
this.latestLrsSettings = message;
receivedSettingsForThisStream = true;
});
this.lrsCall.on('error', (error: ServiceError) => {
this.lrsCall.on('status', (streamStatus: StatusObject) => {
trace(
'LRS stream ended. code=' + error.code + ' details= ' + error.details
'LRS stream ended. code=' + streamStatus.code + ' details= ' + streamStatus.details
);
this.lrsCall = null;
clearInterval(this.statsTimer);
@ -623,6 +627,7 @@ export class XdsClient {
this.maybeStartLrsStream();
}
});
this.lrsCall.on('error', () => {});
/* Send buffered stats information when starting LRS stream. If there is no
* buffered stats information, it will still send the node field. */
this.sendStats();