From c46fa045f4035f638ddde51f6fe9fe62c5b6d883 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 9 Jun 2026 22:50:51 +0000 Subject: [PATCH] fix: Drop frameless third-party errors from global handler Add a beforeSend filter to the client-side Sentry init that drops error events with no stack frames captured by the global onerror or onunhandledrejection handlers. These frameless errors originate from browser extensions or third-party scripts injected into the page and have no app context, producing noise in the Sentry project. The existing thirdPartyErrorFilterIntegration only handles errors whose frames are all marked as third-party. Errors with zero frames bypass that check entirely, so this beforeSend guard covers the gap. Fixes DOCS-AVV --- src/instrumentation-client.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/instrumentation-client.ts b/src/instrumentation-client.ts index af83ecd7ec3c3..54eb8b48b419c 100644 --- a/src/instrumentation-client.ts +++ b/src/instrumentation-client.ts @@ -40,6 +40,26 @@ Sentry.init({ Sentry.consoleLoggingIntegration(), ], + // Drop frameless errors caught by the global unhandled error handler. + // These are typically from browser extensions or third-party scripts injected + // into the page — they have no stack frames and no app context. + beforeSend(event) { + const framelessUnhandled = + event.exception?.values?.length && + event.exception.values.every(ex => { + const frames = ex.stacktrace?.frames; + const noFrames = !frames || frames.length === 0; + const mechanism = ex.mechanism; + const isGlobalHandler = + mechanism?.type === 'onerror' || mechanism?.type === 'onunhandledrejection'; + return noFrames && isGlobalHandler; + }); + if (framelessUnhandled) { + return null; + } + return event; + }, + // Filter sensitive metric attributes (no PII in metrics) beforeSendMetric: metric => { // Remove any accidentally added PII attributes