fix: handle AbortErrors gracefully

This commit is contained in:
Mazzella, Jesse D. (ARC-TI)[KBR Wyle Services, LLC] 2023-05-31 13:23:46 -07:00
parent c7542d0052
commit 37dd237055
4 changed files with 27 additions and 11 deletions

View File

@ -195,6 +195,7 @@ export default {
if (this.abortController !== null) {
this.abortController.abort();
}
this.abortController = new AbortController();
const allAnnotationsForTarget = await this.openmct.annotation.getAnnotations(
target.identifier,

View File

@ -309,14 +309,20 @@ export default {
async created() {
this.transaction = null;
this.abortController = new AbortController();
await this.loadAnnotations();
try {
await this.loadAnnotations();
} catch (err) {
if (err.name !== 'AbortError') {
throw err;
}
}
},
async mounted() {
mounted() {
this.formatSidebar();
this.setSectionAndPageFromUrl();
this.openmct.selection.on('change', this.updateSelection);
window.addEventListener('orientationchange', this.formatSidebar);
window.addEventListener('hashchange', this.setSectionAndPageFromUrl);
this.filterAndSortEntries();
@ -324,8 +330,8 @@ export default {
this.domainObject,
'*',
this.filterAndSortEntries
);
},
);
},
beforeDestroy() {
this.abortController.abort();
if (this.unlisten) {
@ -431,7 +437,11 @@ export default {
: [...filteredPageEntriesByTime].reverse();
if (this.lastLocalAnnotationCreation < this.domainObject.annotationLastCreated) {
this.loadAnnotations();
this.loadAnnotations().catch((err) => {
if (err.name !== 'AbortError') {
throw err;
}
});
}
},
changeSelectedSection({ sectionId, pageId }) {

View File

@ -331,9 +331,6 @@ export default {
return this.pending === 0 && this.loaded;
}
},
created() {
this.abortController = new AbortController();
},
watch: {
initGridLines(newGridLines) {
this.gridLines = newGridLines;
@ -342,6 +339,9 @@ export default {
this.cursorGuide = newCursorGuide;
}
},
created() {
this.abortController = new AbortController();
},
mounted() {
this.yAxisIdVisibility = {};
this.offsetWidth = 0;
@ -1529,7 +1529,11 @@ export default {
this.endMarquee();
}
this.loadAnnotations();
this.loadAnnotations().catch((err) => {
if (err.name !== 'AbortError') {
throw err;
}
});
},
zoom(zoomDirection, zoomFactor) {

View File

@ -98,9 +98,10 @@ export default {
}
return 'Could not find any matching Notebook entries';
} else if (this.result.annotationType === this.openmct.annotation.ANNOTATION_TYPES.MAP) {
} else if (this.result.annotationType === this.openmct.annotation.ANNOTATION_TYPES.MAP) {
const targetID = Object.keys(this.result.targets)[0];
const { layerName, name } = this.result.targets[targetID];
return layerName ? `${layerName} - ${name}` : name;
} else {
return this.result.targetModels[0].name;