From 244e3b7938f07bcc967842a14d8ec9e417b634ef Mon Sep 17 00:00:00 2001 From: Jamie V Date: Thu, 24 Aug 2023 14:17:58 -0700 Subject: [PATCH] [Aborts] Abort Telemetry Collections requests on Navigation, Add abort functionality to getLimits (#6872) * debug * abort any pending requests on router "change:path" event, this should catch cases where the UI is bogged down and doesnt destroy the tc first * english * cant always be on * adding abort to limits requests * finally-ing off the promise * need to just return the object not the property * sticking with the try/catch structure we use elsewhere * removing abort on nav, as views should be calling destroy --------- Co-authored-by: John Hill Co-authored-by: Shefali Joshi --- src/api/telemetry/TelemetryAPI.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/api/telemetry/TelemetryAPI.js b/src/api/telemetry/TelemetryAPI.js index 050cdcce04..00df1b69d4 100644 --- a/src/api/telemetry/TelemetryAPI.js +++ b/src/api/telemetry/TelemetryAPI.js @@ -784,6 +784,7 @@ export default class TelemetryAPI { */ getLimits(domainObject) { const provider = this.#findLimitEvaluator(domainObject); + if (!provider || !provider.getLimits) { return { limits: function () { @@ -792,7 +793,23 @@ export default class TelemetryAPI { }; } - return provider.getLimits(domainObject); + const abortController = new AbortController(); + const options = { signal: abortController.signal }; + this.requestAbortControllers.add(abortController); + + try { + return provider.getLimits(domainObject, options); + } catch (error) { + if (error.name !== 'AbortError') { + this.openmct.notifications.error( + 'Error requesting telemetry data, see console for details' + ); + } + + throw new Error(error); + } finally { + this.requestAbortControllers.delete(abortController); + } } }