diff --git a/web/src/components/repo/build/BuildLog.vue b/web/src/components/repo/build/BuildLog.vue index 7e4ab9260..b5bca6780 100644 --- a/web/src/components/repo/build/BuildLog.vue +++ b/web/src/components/repo/build/BuildLog.vue @@ -167,11 +167,16 @@ export default defineComponent({ fitAddon.value.fit(); } + const unmounted = ref(false); onMounted(async () => { term.value.loadAddon(fitAddon.value); term.value.loadAddon(new WebLinksAddon()); await nextTick(() => { + if (unmounted.value) { + // need to check if unmounted already because we are async here + return; + } const element = document.getElementById('terminal'); if (element === null) { throw new Error('Unexpected: "terminal" should be provided at this place'); @@ -214,9 +219,15 @@ export default defineComponent({ ); onBeforeUnmount(() => { + unmounted.value = true; if (stream.value) { stream.value.close(); } + const element = document.getElementById('terminal'); + if (element !== null) { + // Clean up any custom DOM added in onMounted above + element.innerHTML = ''; + } window.removeEventListener('resize', resize); });