From e56c673005397728ef51f14fc098165858c5acc6 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Fri, 17 Sep 2021 17:50:53 -0700 Subject: [PATCH] [Telemetry Collections] Add process method to historical request options (for yield requests) (#4201) * added processor generator to request options in the telemetry API. Allows progressive yielding of request results. Co-authored-by: Andrew Henry --- src/api/telemetry/TelemetryCollection.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/api/telemetry/TelemetryCollection.js b/src/api/telemetry/TelemetryCollection.js index 5574d197c5..66c5959632 100644 --- a/src/api/telemetry/TelemetryCollection.js +++ b/src/api/telemetry/TelemetryCollection.js @@ -115,6 +115,7 @@ export class TelemetryCollection extends EventEmitter { this._requestHistoricalTelemetry(); } + /** * If a historical provider exists, then historical requests will be made * @private @@ -126,20 +127,25 @@ export class TelemetryCollection extends EventEmitter { let historicalData; + this.options.onPartialResponse = this._processNewTelemetry.bind(this); + try { this.requestAbort = new AbortController(); this.options.signal = this.requestAbort.signal; historicalData = await this.historicalProvider.request(this.domainObject, this.options); - this.requestAbort = undefined; } catch (error) { - console.error('Error requesting telemetry data...'); - this.requestAbort = undefined; - this._error(error); + if (error.name !== 'AbortError') { + console.error('Error requesting telemetry data...'); + this._error(error); + } } + this.requestAbort = undefined; + this._processNewTelemetry(historicalData); } + /** * This uses the built in subscription function from Telemetry API * @private