From cb00786f1e7ffcadf2b9da87bfffa8e875a1a28b Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 14 Jul 2022 20:41:17 +0900 Subject: [PATCH] improve error handling of client boot --- packages/backend/src/server/web/boot.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/backend/src/server/web/boot.js b/packages/backend/src/server/web/boot.js index f3116eb653..fa3ebbc2a2 100644 --- a/packages/backend/src/server/web/boot.js +++ b/packages/backend/src/server/web/boot.js @@ -59,6 +59,7 @@ import(`/assets/${CLIENT_ENTRY}`) .catch(async e => { await checkUpdate(); + console.error(e); renderError('APP_FETCH_FAILED', e); }) //#endregion @@ -271,17 +272,22 @@ // eslint-disable-next-line no-inner-declarations async function checkUpdate() { - // TODO: サーバーが落ちている場合などのエラーハンドリング - const res = await fetch('/api/meta', { - method: 'POST', - cache: 'no-cache' - }); + try { + const res = await fetch('/api/meta', { + method: 'POST', + cache: 'no-cache' + }); - const meta = await res.json(); + const meta = await res.json(); - if (meta.version != v) { - localStorage.setItem('v', meta.version); - refresh(); + if (meta.version != v) { + localStorage.setItem('v', meta.version); + refresh(); + } + } catch (e) { + console.error(e); + renderError('UPDATE_CHECK_FAILED', e); + throw e; } }