From e7c583f312a5290bb23f18a414e73556138a1da7 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Wed, 8 Jan 2025 10:44:21 -0500 Subject: [PATCH] MM-62371 Add additional error handling to PerformanceReporter (#29774) As in the comments I added, this is to fix an error introduced by changes made by either Firefox or 1Password due to accessing a performance metric's details field when we're not allowed to. --- .../utils/performance_telemetry/reporter.ts | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/webapp/channels/src/utils/performance_telemetry/reporter.ts b/webapp/channels/src/utils/performance_telemetry/reporter.ts index e3aaaa4bd9..64f566c9b9 100644 --- a/webapp/channels/src/utils/performance_telemetry/reporter.ts +++ b/webapp/channels/src/utils/performance_telemetry/reporter.ts @@ -196,7 +196,16 @@ export default class PerformanceReporter { } private handleMeasure(entry: PerformanceMeasure) { - if (!entry.detail?.report) { + let report; + try { + report = Boolean(entry.detail?.report); + } catch { + // Measures recorded by browser extensions may be in a separate context which causes accessing + // entry.detail to throw an error + report = false; + } + + if (!report) { return; } @@ -209,7 +218,16 @@ export default class PerformanceReporter { } private handleMark(entry: PerformanceMeasure) { - if (!entry.detail?.report) { + let report; + try { + report = Boolean(entry.detail?.report); + } catch { + // Measures recorded by browser extensions may be in a separate context which causes accessing + // entry.detail to throw an error + report = false; + } + + if (!report) { return; }