From 34bbd415479efa3756adfcfd05c252b4de8b49d6 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 27 Oct 2023 10:19:33 -0700 Subject: [PATCH] If unable to load main bundle, retry after 3 seconds Summary: If we fail to load the main js bundle, retry after 3 seconds. Reviewed By: aigoncharov Differential Revision: D50732857 fbshipit-source-id: b19ea165776f8105d724e586b1bed20bf1f5178c --- desktop/static/index.web.dev.html | 14 ++++++++++++-- desktop/static/index.web.html | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/desktop/static/index.web.dev.html b/desktop/static/index.web.dev.html index d5eda16f505..0c3606a0a9b 100644 --- a/desktop/static/index.web.dev.html +++ b/desktop/static/index.web.dev.html @@ -201,9 +201,19 @@ function init() { const script = document.createElement('script'); script.src = window.flipperConfig.entryPoint; - script.onerror = (e) => { - showMessage('Failed to load entry point. Check Chrome Dev Tools console for more info.'); + const retry = (retries) => { + showMessage(`Failed to load entry point. Check Chrome Dev Tools console for more info. Retrying in: ${retries}`); + retries -= 1; + if (retries < 0) { + window.location.reload(); + } + else { + setTimeout(() => retry(retries), 1000); + } + } + + retry(3); }; document.body.appendChild(script); diff --git a/desktop/static/index.web.html b/desktop/static/index.web.html index c724d704132..80c2bdc17a9 100644 --- a/desktop/static/index.web.html +++ b/desktop/static/index.web.html @@ -106,9 +106,19 @@ function init() { const script = document.createElement('script'); script.src = window.flipperConfig.entryPoint; - script.onerror = (e) => { - showMessage('Script failure. Check Chrome Dev Tools console for more info.'); + const retry = (retries) => { + showMessage(`Failed to load entry point. Check Chrome Dev Tools console for more info. Retrying in: ${retries}`); + retries -= 1; + if (retries < 0) { + window.location.reload(); + } + else { + setTimeout(() => retry(retries), 1000); + } + } + + retry(3); }; document.body.appendChild(script);