The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: remove noise from Sentry (#42878)
Ali Waseem4d369515bc26
diff --git a/apps/studio/instrumentation-client.test.ts b/apps/studio/instrumentation-client.test.tsnew file mode 100644index 00000000000..c8f5d1aab13--- /dev/null+++ b/apps/studio/instrumentation-client.test.ts@@ -0,0 +1,419 @@+import type { Event as SentryEvent, StackFrame } from '@sentry/nextjs'+import { describe, expect, it } from 'vitest'++import {+ isBrowserWalletExtensionError,+ isCancellationRejection,+ isChallengeExpiredError,+ isUserAbortedOperation,+} from './instrumentation-client'++describe('Sentry beforeSend filtering functions', () => {+ describe('isBrowserWalletExtensionError', () => {+ it('returns true for Gate.io wallet extension error (gt-window-provider.js)', () => {+ const event: SentryEvent = {+ exception: {+ values: [+ {+ type: 'TypeError',+ value: 'en.shouldSetTallyForCurrentProvider is not a function',+ stacktrace: {+ frames: [+ { filename: 'app:///_next/static/chunks/main.js' } as StackFrame,+ { filename: 'app:///gt-window-provider.js' } as StackFrame,+ ],+ },+ },+ ],+ },+ }++ expect(isBrowserWalletExtensionError(event)).toBe(true)+ })++ it('returns true for Gate.io BTC wallet extension error (gt-window-provider-btc.js)', () => {+ const event: SentryEvent = {+ exception: {+ values: [+ {+ type: 'TypeError',+ value: 'f.shouldSetTallyForCurrentProvider is not a function',+ stacktrace: {+ frames: [{ filename: 'app:///gt-window-provider-btc.js' } as StackFrame],+ },+ },+ ],+ },+ }++ expect(isBrowserWalletExtensionError(event)).toBe(true)+ })++ it('returns true for wallet-provider in abs_path', () => {+ const event: SentryEvent = {+ exception: {+ values: [+ {+ type: 'Error',+ value: 'wallet error',+ stacktrace: {+ frames: [+ { abs_path: 'chrome-extension://abc123/wallet-provider.js' } as StackFrame,+ ],+ },+ },+ ],+ },+ }++ expect(isBrowserWalletExtensionError(event)).toBe(true)+ })++ it('returns false for regular application errors', () => {+ const event: SentryEvent = {+ exception: {+ values: [+ {+ type: 'Error',+ value: 'Regular error',+ stacktrace: {+ frames: [+ { filename: 'app:///_next/static/chunks/main.js' } as StackFrame,+ { filename: 'app:///_next/static/chunks/pages/index.js' } as StackFrame,+ ],+ },+ },+ ],+ },+ }++ expect(isBrowserWalletExtensionError(event)).toBe(false)+ })++ it('returns false for empty event', () => {+ const event: SentryEvent = {}+ expect(isBrowserWalletExtensionError(event)).toBe(false)+ })++ it('returns false when exception values are empty', () => {+ const event: SentryEvent = {+ exception: {+ values: [],+ },+ }+ expect(isBrowserWalletExtensionError(event)).toBe(false)+ })++ it('returns false when stacktrace frames are undefined', () => {+ const event: SentryEvent = {+ exception: {+ values: [+ {+ type: 'Error',+ value: 'Error without stacktrace',+ },+ ],+ },+ }+ expect(isBrowserWalletExtensionError(event)).toBe(false)+ })+ })++ describe('isUserAbortedOperation', () => {+ it('returns true for "operation was aborted" error', () => {+ const error = new Error('The operation was aborted.')+ const event: SentryEvent = {}++ expect(isUserAbortedOperation(error, event)).toBe(true)+ })++ it('returns true for "signal is aborted" error', () => {+ const error = new Error('signal is aborted without reason')+ const event: SentryEvent = {}++ expect(isUserAbortedOperation(error, event)).toBe(true)+ })++ it('returns true for "manually canceled" error', () => {+ const error = new Error('operation is manually canceled')+ const event: SentryEvent = {}++ expect(isUserAbortedOperation(error, event)).toBe(true)+ })++ it('returns true for "AbortError" message', () => {+ const error = new Error('AbortError: The operation was aborted')+ const event: SentryEvent = {}++ expect(isUserAbortedOperation(error, event)).toBe(true)+ })++ it('returns true when message is in event.message (no error object)', () => {+ const error = null+ const event: SentryEvent = {+ message: '[CRITICAL][sign in via EP] Failed: The operation was aborted.',+ }++ expect(isUserAbortedOperation(error, event)).toBe(true)+ })++ it('returns true for event message with "signal is aborted"', () => {+ const event: SentryEvent = {+ message: '[CRITICAL][sign in via EP] Failed: signal is aborted without reason',+ }++ expect(isUserAbortedOperation(undefined, event)).toBe(true)+ })++ it('returns false for regular errors', () => {+ const error = new Error('Something went wrong')+ const event: SentryEvent = {}++ expect(isUserAbortedOperation(error, event)).toBe(false)+ })++ it('returns false for empty inputs', () => {+ expect(isUserAbortedOperation(null, {})).toBe(false)+ expect(isUserAbortedOperation(undefined, {})).toBe(false)+ })++ it('handles non-Error objects gracefully', () => {+ const error = { message: 'The operation was aborted.' }+ const event: SentryEvent = {}++ // Non-Error objects should not match since we check instanceof Error+ expect(isUserAbortedOperation(error, event)).toBe(false)+ })+ })++ describe('isCancellationRejection', () => {+ it('returns true for cancellation type in extra.__serialized__', () => {+ const event: SentryEvent = {+ extra: {+ __serialized__: {+ msg: 'operation is manually canceled',+ type: 'cancelation',+ },+ },+ }++ expect(isCancellationRejection(event)).toBe(true)+ })++ it('returns false when type is not cancelation', () => {+ const event: SentryEvent = {+ extra: {+ __serialized__: {+ msg: 'some error',+ type: 'error',+ },+ },+ }++ expect(isCancellationRejection(event)).toBe(false)+ })++ it('returns false when __serialized__ is undefined', () => {+ const event: SentryEvent = {+ extra: {},+ }++ expect(isCancellationRejection(event)).toBe(false)+ })++ it('returns false when extra is undefined', () => {+ const event: SentryEvent = {}++ expect(isCancellationRejection(event)).toBe(false)+ })++ it('returns false when __serialized__ has no type property', () => {+ const event: SentryEvent = {+ extra: {+ __serialized__: {+ msg: 'some message',+ },+ },+ }++ expect(isCancellationRejection(event)).toBe(false)+ })+ })++ describe('isChallengeExpiredError', () => {+ it('returns true for challenge-expired error message', () => {+ const error = new Error('Non-Error promise rejection captured with value: challenge-expired')+ const event: SentryEvent = {}++ expect(isChallengeExpiredError(error, event)).toBe(true)+ })++ it('returns true when challenge-expired is in event.message', () => {+ const event: SentryEvent = {+ message: 'challenge-expired',+ }++ expect(isChallengeExpiredError(null, event)).toBe(true)+ })++ it('returns false for regular errors', () => {+ const error = new Error('Something went wrong')+ const event: SentryEvent = {}++ expect(isChallengeExpiredError(error, event)).toBe(false)+ })++ it('returns false for empty inputs', () => {+ expect(isChallengeExpiredError(null, {})).toBe(false)+ expect(isChallengeExpiredError(undefined, {})).toBe(false)+ })++ it('returns false for similar but different messages', () => {+ const error = new Error('challenge expired') // No hyphen+ const event: SentryEvent = {}++ expect(isChallengeExpiredError(error, event)).toBe(false)+ })+ })++ describe('integration scenarios', () => {+ it('correctly identifies SUPABASE-APP-353 pattern (cancellation rejection)', () => {+ // Based on actual Sentry issue SUPABASE-APP-353+ const event: SentryEvent = {+ exception: {+ values: [+ {+ type: 'UnhandledRejection',+ value: 'Object captured as promise rejection with keys: msg, type',+ },+ ],+ },+ extra: {+ __serialized__: {+ msg: 'operation is manually canceled',+ type: 'cancelation',+ },+ },+ }++ expect(isCancellationRejection(event)).toBe(true)+ })++ it('correctly identifies SUPABASE-APP-AFC pattern (wallet extension)', () => {+ // Based on actual Sentry issue SUPABASE-APP-AFC+ const event: SentryEvent = {+ exception: {+ values: [+ {+ type: 'TypeError',+ value: 'f.shouldSetTallyForCurrentProvider is not a function',+ stacktrace: {+ frames: [+ {+ filename:+ 'node_modules/.pnpm/@[email protected]/node_modules/@sentry/browser/src/helpers.ts',+ function: 'n',+ } as StackFrame,+ {+ filename: 'app:///gt-window-provider-btc.js',+ function: 'GateWindowProvider.internalListener',+ } as StackFrame,+ ],+ },+ },+ ],+ },+ }++ expect(isBrowserWalletExtensionError(event)).toBe(true)+ })++ it('correctly identifies SUPABASE-APP-92A pattern (wallet extension)', () => {+ // Based on actual Sentry issue SUPABASE-APP-92A+ const event: SentryEvent = {+ exception: {+ values: [+ {+ type: 'TypeError',+ value: 'en.shouldSetTallyForCurrentProvider is not a function',+ stacktrace: {+ frames: [+ {+ filename:+ 'node_modules/.pnpm/@[email protected]/node_modules/@sentry/browser/src/helpers.ts',+ function: 'n',+ } as StackFrame,+ {+ filename: 'app:///gt-window-provider.js',+ function: 'GateWindowProvider.internalListener',+ } as StackFrame,+ ],+ },+ },+ ],+ },+ }++ expect(isBrowserWalletExtensionError(event)).toBe(true)+ })++ it('correctly identifies SUPABASE-APP-BG6 pattern (user aborted)', () => {+ // Based on actual Sentry issue SUPABASE-APP-BG6+ const error = new Error('The operation was aborted.')+ const event: SentryEvent = {+ message: '[CRITICAL][sign in via EP] Failed: The operation was aborted.',+ }++ expect(isUserAbortedOperation(error, event)).toBe(true)+ })++ it('correctly identifies SUPABASE-APP-BG7 pattern (signal aborted)', () => {+ // Based on actual Sentry issue SUPABASE-APP-BG7+ const error = new Error('signal is aborted without reason')+ const event: SentryEvent = {+ message: '[CRITICAL][sign in via EP] Failed: signal is aborted without reason',+ }++ expect(isUserAbortedOperation(error, event)).toBe(true)+ })++ it('correctly identifies SUPABASE-APP-ACC pattern (challenge expired)', () => {+ // Based on actual Sentry issue SUPABASE-APP-ACC+ const error = new Error('Non-Error promise rejection captured with value: challenge-expired')+ const event: SentryEvent = {+ exception: {+ values: [+ {+ type: 'UnhandledRejection',+ value: 'Non-Error promise rejection captured with value: challenge-expired',+ },+ ],+ },+ }++ expect(isChallengeExpiredError(error, event)).toBe(true)+ })++ it('does not filter legitimate errors', () => {+ const error = new Error('Cannot read property "foo" of undefined')+ const event: SentryEvent = {+ exception: {+ values: [+ {+ type: 'TypeError',+ value: 'Cannot read property "foo" of undefined',+ stacktrace: {+ frames: [{ filename: 'app:///_next/static/chunks/pages/index.js' } as StackFrame],+ },+ },+ ],+ },+ }++ expect(isBrowserWalletExtensionError(event)).toBe(false)+ expect(isUserAbortedOperation(error, event)).toBe(false)+ expect(isCancellationRejection(event)).toBe(false)+ expect(isChallengeExpiredError(error, event)).toBe(false)+ })+ })+})diff --git a/apps/studio/instrumentation-client.ts b/apps/studio/instrumentation-client.tsindex 5dd543ad6d3..6f24298c4d8 100644--- a/apps/studio/instrumentation-client.ts+++ b/apps/studio/instrumentation-client.ts@@ -3,8 +3,6 @@// https://docs.sentry.io/platforms/javascript/guides/nextjs/import * as Sentry from '@sentry/nextjs'-import { match } from 'path-to-regexp'-import { hasConsented } from 'common'import { IS_PLATFORM } from 'common/constants/environment'import { MIRRORED_BREADCRUMBS } from 'lib/breadcrumbs'@@ -50,6 +48,52 @@ function isThirdPartyError(frames: Sentry.StackFrame[] | undefined) {return !hasAppFrame}+// Filter browser wallet extension errors (e.g., Gate.io wallet)+// These errors come from injected wallet scripts and are not actionable+// Examples: SUPABASE-APP-AFC, SUPABASE-APP-92A+export function isBrowserWalletExtensionError(event: Sentry.Event): boolean {+ const frames = event.exception?.values?.flatMap((e) => e.stacktrace?.frames || []) || []+ return frames.some((frame) => {+ const filename = frame.filename || frame.abs_path || ''+ return filename.includes('gt-window-provider') || filename.includes('wallet-provider')+ })+}++// Filter user-aborted operations (intentional cancellations)+// These are expected when users cancel requests or navigate away+// Examples: SUPABASE-APP-BG6, SUPABASE-APP-BG7+export function isUserAbortedOperation(error: unknown, event: Sentry.Event): boolean {+ const errorMessage = error instanceof Error ? error.message : ''+ const eventMessage = event.message || ''+ const message = errorMessage || eventMessage++ return (+ message.includes('operation was aborted') ||+ message.includes('signal is aborted') ||+ message.includes('manually canceled') ||+ message.includes('AbortError')+ )+}++// Filter cancellation promise rejections (e.g., from query cancellation)+// These occur when operations are intentionally cancelled by the user+// Example: SUPABASE-APP-353 (~466k events)+export function isCancellationRejection(event: Sentry.Event): boolean {+ const serialized = event.extra?.__serialized__ as Record<string, unknown> | undefined+ return serialized?.type === 'cancelation'+}++// Filter challenge/captcha expired errors (user timeout)+// These happen when users don't complete captcha in time - expected behavior+// Example: SUPABASE-APP-ACC+export function isChallengeExpiredError(error: unknown, event: Sentry.Event): boolean {+ const errorMessage = error instanceof Error ? error.message : ''+ const eventMessage = event.message || ''+ const message = errorMessage || eventMessage++ return message.includes('challenge-expired')+}+Sentry.init({dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,...(process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT && {@@ -120,6 +164,19 @@ Sentry.init({return null}+ if (isBrowserWalletExtensionError(event)) {+ return null+ }+ if (isUserAbortedOperation(hint.originalException, event)) {+ return null+ }+ if (isCancellationRejection(event)) {+ return null+ }+ if (isChallengeExpiredError(hint.originalException, event)) {+ return null+ }+if (event.breadcrumbs) {event.breadcrumbs = sanitizeArrayOfObjects(event.breadcrumbs) as Sentry.Breadcrumb[]}@@ -130,6 +187,8 @@ Sentry.init({'ResizeObserver','s.getModifierState is not a function',/^Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope'/,+ // Browser wallet extension errors (e.g., Gate.io wallet)+ 'shouldSetTallyForCurrentProvider is not a function',// [Joshen] We currently use stripe-js for customers to save their credit card data// I'm unable to reproduce this error on local, staging nor prod across chrome, safari or firefox// Based on https://github.com/stripe/stripe-js/issues/26, it seems like this error is safe to ignore,@@ -153,6 +212,8 @@ Sentry.init({/504 Gateway Time-out/,// [Joshen] This is the one caused by Google translate in the browser + 3rd party extensions'Node.insertBefore: Child to insert before is not a child of this node',+ // [Ali] Google Translate / browser extension DOM manipulation errors+ 'NotFoundError: The object can not be found here.',// [Joshen] This one sprung up recently and I've no idea where this is coming from'r.default.setDefaultLevel is not a function',// [Joshen] Safe to ignore, it an error from the copyToClipboard@@ -160,31 +221,5 @@ Sentry.init({],})-// Replace dynamic query param with a template text-// Support grouping sentry transaction-function standardiseRouterUrl(url: string) {- let finalUrl = url-- const orgMatch = match('/org/:slug{/*path}', { decode: decodeURIComponent })- const orgMatchResult = orgMatch(finalUrl)- if (orgMatchResult) {- finalUrl = finalUrl.replace((orgMatchResult.params as any).slug, '[slug]')- }-- const newOrgMatch = match('/new/:slug', { decode: decodeURIComponent })- const newOrgMatchResult = newOrgMatch(finalUrl)- if (newOrgMatchResult) {- finalUrl = finalUrl.replace((newOrgMatchResult.params as any).slug, '[slug]')- }-- const projectMatch = match('/project/:ref{/*path}', { decode: decodeURIComponent })- const projectMatchResult = projectMatch(finalUrl)- if (projectMatchResult) {- finalUrl = finalUrl.replace((projectMatchResult.params as any).ref, '[ref]')- }-- return finalUrl-}-// This export will instrument router navigations, and is only relevant if you enable tracing.export const onRouterTransitionStart = Sentry.captureRouterTransitionStart