fix(sdk): drop unhandled rejection noise from browser extensions in beforeSend#119463
Draft
billyvg wants to merge 8 commits into
Draft
fix(sdk): drop unhandled rejection noise from browser extensions in beforeSend#119463billyvg wants to merge 8 commits into
billyvg wants to merge 8 commits into
Conversation
Simplify the logic a bit Simplify the logic a bit
Add a deterministic, local conversion from "humanized" ESQ, i.e. the shape
filter chips already render in ("is unresolved assigned is me"), back
to real ESQ ("is:unresolved assigned:me"), surfaced as one suggestion in
the search bar's free-text dropdown.
This reverts commit aaaed59.
MetaMask and other crypto-wallet Chrome extensions propagate their own unhandled rejections (e.g. error code 4001 "User Rejected Request") into the host page's global unhandledrejection handler. These arrive as plain objects (not Error instances) with a stack trace pointing at a chrome-extension:// or moz-extension:// URL and are never actionable by Sentry engineers. Add isBrowserExtensionError() to beforeSend that returns null for these events, keyed on: 1. mechanism type auto.browser.global_handlers.onunhandledrejection 2. originalException is a non-Error plain object whose .stack contains chrome-extension:// or moz-extension:// Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
📊 Type Coverage Diff
🔍 3 new type safety issues introducedNon-null assertions (
Type assertions (
This is informational only and does not block the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Drop
UnhandledRejectionevents that originate from browser extensions (MetaMask, other crypto-wallet content scripts) — they are third-party noise, never actionable by Sentry engineers.Problem
Browser extensions like MetaMask fire their own unhandled promise rejections (e.g. error code 4001 — "MetaMask Personal Sign: User denied message signature") into the host page's global
unhandledrejectionhandler. The Sentry SDK captures these and reports them as real issues.The
thirdPartyErrorFilterIntegrationis configured withbehaviour: 'apply-tag-if-contains-third-party-frames', which only tags events — it does not drop them. So these extension events make it all the way to Sentry.Characteristics of the noise:
mechanism.type === 'auto.browser.global_handlers.onunhandledrejection'originalExceptionis a plain object (not anError) with a.stackproperty pointing atchrome-extension://ormoz-extension://Fix
Add
isBrowserExtensionError(event, hint)and call it inbeforeSend. It returnstrue(→null→ dropped) when:onunhandledrejectionhint.originalExceptionis a non-Error plain object with a.stackstring containingchrome-extension://ormoz-extension://This is intentionally narrow: it only drops events where the original rejection value itself points at an extension, not events where an extension merely appears somewhere in the stack of a real Error.
Evidence
Triggered by an alert for event
0a22da40441f40ba85512dfdf107649bon the/explore/traces/page. Full stack trace was:No Sentry frames. The rejection value was
{code: 4001, message: "...", stack: "...chrome-extension://..."}— a plain object, not an Error.Session
https://claude.ai/code/session_015Gd856MCZWtWz8VmqLdaA3
Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
Generated by Claude Code