Skip to content

Commit

Permalink
Prevent logging network errors
Browse files Browse the repository at this point in the history
  • Loading branch information
WesselKroos committed Sep 16, 2024
1 parent 40819ef commit 4d7c26d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
5 changes: 4 additions & 1 deletion src/scripts/libs/ambientlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,10 @@ export default class Ambientlight {
if (this.chromiumBugVideoJitterWorkaround?.update)
this.chromiumBugVideoJitterWorkaround.update();
} catch (ex) {
if (!isNetworkError(ex)) {
if (
!['InvalidStateError', 'SecurityError'].includes(ex?.name) &&
!isNetworkError(ex)
) {
SentryReporter.captureException(ex);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/libs/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,8 @@ export const setWarning = (text) => {
};

export const isNetworkError = (ex) =>
ex?.message !== 'Failed to fetch' && // Chromium
ex?.message !== 'NetworkError when attempting to fetch resource.'; // Firefox
ex?.message === 'Failed to fetch' || // Chromium
ex?.message === 'NetworkError when attempting to fetch resource.'; // Firefox

export const setStyleProperty = (elem, name, value, priority = '') => {
const currentValue = elem.style.getPropertyValue(name) ?? '';
Expand Down
14 changes: 1 addition & 13 deletions src/scripts/libs/static-image-detection.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { appendErrorStack, isNetworkError } from './generic';
import { appendErrorStack } from './generic';
import { workerFromCode } from './worker';

const workerCode = function () {
Expand Down Expand Up @@ -239,18 +239,6 @@ const workerCode = function () {
difference,
});
} catch (ex) {
if (
isNetworkError(ex) ||
['InvalidStateError', 'SecurityError'].includes(ex?.name)
) {
this.postMessage({
id,
baseUrl,
difference: 1,
});
return;
}

this.postMessage({
id,
baseUrl,
Expand Down

0 comments on commit 4d7c26d

Please sign in to comment.