Skip to content

Commit

Permalink
[Aborts] Abort Telemetry Collections requests on Navigation, Add abor…
Browse files Browse the repository at this point in the history
…t 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 <[email protected]>
Co-authored-by: Shefali Joshi <[email protected]>
  • Loading branch information
3 people authored Aug 24, 2023
1 parent 42b13c4 commit 244e3b7
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/api/telemetry/TelemetryAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ export default class TelemetryAPI {
*/
getLimits(domainObject) {
const provider = this.#findLimitEvaluator(domainObject);

if (!provider || !provider.getLimits) {
return {
limits: function () {
Expand All @@ -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);
}
}
}

Expand Down

0 comments on commit 244e3b7

Please sign in to comment.