Skip to content

Commit

Permalink
If unable to load main bundle, retry after 3 seconds
Browse files Browse the repository at this point in the history
Summary: If we fail to load the main js bundle, retry after 3 seconds.

Reviewed By: aigoncharov

Differential Revision: D50732857

fbshipit-source-id: b19ea165776f8105d724e586b1bed20bf1f5178c
  • Loading branch information
lblasa authored and facebook-github-bot committed Oct 27, 2023
1 parent 2c1e814 commit 34bbd41
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 12 additions & 2 deletions desktop/static/index.web.dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 12 additions & 2 deletions desktop/static/index.web.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 34bbd41

Please sign in to comment.