Skip to content

Commit

Permalink
Add alert when the page fails to load due to Knockout binding failure
Browse files Browse the repository at this point in the history
  • Loading branch information
wormania committed Nov 30, 2023
1 parent 567473c commit c14b784
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -78188,6 +78188,19 @@ const alert = (message, type = 'primary', timeout = 5e3) => {
}, timeout);
}

window.addEventListener("error", (event) => {
// Handle KO binding errors, usually occur when knockout is trying to use functions that
// don't exist in the cached javascript, but could also be a genuine error that slipped through
if (event?.error?.message?.startsWith("Unable to process binding")) {
alert(
`There was an error loading the page. Hard Refresh (Ctrl+F5 or Cmd+Shift+R) to clear the cache.
If this persists please post in #wiki-general on discord.`,
'danger',
3600e3
);
}
});

module.exports = {
alert,
};
Expand Down
13 changes: 13 additions & 0 deletions scripts/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ const alert = (message, type = 'primary', timeout = 5e3) => {
}, timeout);
}

window.addEventListener("error", (event) => {
// Handle KO binding errors, usually occur when knockout is trying to use functions that
// don't exist in the cached javascript, but could also be a genuine error that slipped through
if (event?.error?.message?.startsWith("Unable to process binding")) {
alert(
`There was an error loading the page. Hard Refresh (Ctrl+F5 or Cmd+Shift+R) to clear the cache.
If this persists please post in #wiki-general on discord.`,
'danger',
3600e3
);
}
});

module.exports = {
alert,
};

0 comments on commit c14b784

Please sign in to comment.