[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 <john.c.hill@nasa.gov>
Co-authored-by: Shefali Joshi <simplyrender@gmail.com>
This commit is contained in:
Jamie V 2023-08-24 14:17:58 -07:00 committed by GitHub
parent 42b13c4dfb
commit 244e3b7938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}
}
}