Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error-Handler: Ignore errors if the browser is outdated. Fixes #644 #1154

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/error-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ const isNetworkError = (message) => {
if (message === 'NetworkError when attempting to fetch resource.') return true;
return false;
};

/**
* Heuristic to determine if the browser is too old. Uses a somewhat recent language feature to check if it is supported.
* @returns {boolean}
*/
const isBrowserDeprecated = () => {
try {
Object.fromEntries(new Map([['a', 'b']]));
} catch (e) {
return true;
}
return false;
};

try {
const handler = (event) => {
try {
Expand All @@ -101,6 +115,14 @@ try {
return;
}

if (isBrowserDeprecated()) {
// eslint-disable-next-line no-console
console.error(
'If you are reading this: An error occurred, but your browser is outdated and therefore unsupported.\nConsider upgrading your browser.'
);
return;
}

if (event.error?.no_side_effects && isNetworkError(event.error.message)) {
if (!window.navigator.onLine) {
// seems like we don't have a network connection in the first place
Expand Down