From 0bdd4b3d44ae4a30d80616f8289db242ceb0b833 Mon Sep 17 00:00:00 2001 From: James Lyne Date: Wed, 19 May 2021 00:37:12 +0100 Subject: [PATCH] Fix aborted configuration requests being retried --- src/App.vue | 9 +++++++++ src/api.ts | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/App.vue b/src/App.vue index b28dc7d..6414a8a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -57,6 +57,11 @@ export default defineComponent({ startUpdates(); requestAnimationFrame(() => window.hideSplash()); } catch(e) { + //Request was aborted, probably because another server was selected before the request finished. Don't retry + if(e instanceof DOMException && e.name === 'AbortError') { + return; + } + const error = `Failed to load server configuration for '${store.state.currentServer}'`; console.error(`${error}:`, e); window.showSplashError(`${error}\n${e}`, false, ++configAttempts.value); @@ -75,6 +80,10 @@ export default defineComponent({ await store.dispatch(ActionTypes.GET_UPDATE, undefined); } finally { if(updatesEnabled.value) { + if(updateTimeout.value) { + clearTimeout(updateTimeout.value); + } + updateTimeout.value = setTimeout(() => update(), updateInterval.value); } } diff --git a/src/api.ts b/src/api.ts index 9e200e6..b8ee146 100644 --- a/src/api.ts +++ b/src/api.ts @@ -653,7 +653,8 @@ async function fetchJSON(url: string, signal: AbortSignal) { response = await fetch(url, {signal}); } catch(e) { if(e instanceof DOMException && e.name === 'AbortError') { - console.warn('Request aborted'); + console.warn(`Request aborted (${url}`); + throw e; } else { console.error(e); }