From 9fce6b1026fa3d9b5320e0911db8d01f055ada79 Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 5 Jan 2021 22:10:25 -0500 Subject: [PATCH] Really ignore ResizeObserver loop errors (cherry picked from commit 99a7540fe4dc5160f6487cfe810e99166ee4582e) --- .../Middleware/createSentryMiddleware.js | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/frontend/src/Store/Middleware/createSentryMiddleware.js b/frontend/src/Store/Middleware/createSentryMiddleware.js index bc1ecf0f6..50b23cda5 100644 --- a/frontend/src/Store/Middleware/createSentryMiddleware.js +++ b/frontend/src/Store/Middleware/createSentryMiddleware.js @@ -3,14 +3,26 @@ import * as Integrations from '@sentry/integrations'; import _ from 'lodash'; import parseUrl from 'Utilities/String/parseUrl'; +const IgnoreErrors = [ + // Innocuous browser errors + /ResizeObserver loop limit exceeded/, + /ResizeObserver loop completed with undelivered notifications/ +]; + function cleanseUrl(url) { const properties = parseUrl(url); return `${properties.pathname}${properties.search}`; } -function cleanseData(data) { - const result = _.cloneDeep(data); +function shouldIgnoreException(s) { + return s && IgnoreErrors.find((pattern) => pattern.test(s)); +} + +function cleanseData(event, hint) { + const result = _.cloneDeep(event); + + const error = hint && hint.originalException; result.transaction = cleanseUrl(result.transaction); @@ -26,6 +38,14 @@ function cleanseData(data) { }); } + if ( + error && + error.message && + shouldIgnoreException(error.message) + ) { + return null; + } + result.request.url = cleanseUrl(result.request.url); return result; @@ -88,7 +108,6 @@ export default function createSentryMiddleware() { environment: branch, release, sendDefaultPii: true, - ignoreErrors: ['ResizeObserver loop limit exceeded'], beforeSend: cleanseData, integrations: [ new Integrations.RewriteFrames({ iteratee: stripUrlBase }),