Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sentry.edge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from '@sentry/nextjs'
import { sentryIgnoreErrors } from './src/utils/sentryIgnoreErrors'

const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN || process.env.SENTRY_DSN

Expand All @@ -16,5 +17,7 @@ if (dsn) {

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,

ignoreErrors: sentryIgnoreErrors,
})
}
3 changes: 2 additions & 1 deletion sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from '@sentry/nextjs'
import { sentryIgnoreErrors } from './src/utils/sentryIgnoreErrors'

const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN || process.env.SENTRY_DSN
const vercelEnv = process.env.NEXT_PUBLIC_VERCEL_ENV
Expand All @@ -20,7 +21,7 @@ if (dsn) {

// Uncomment the line below to enable Spotlight (https://spotlightjs.com)
// spotlight: process.env.NODE_ENV === 'development',
ignoreErrors: [/fetch failed/i, /failed to fetch/i],
ignoreErrors: sentryIgnoreErrors,

beforeSend(event) {
if (!isProd && event.type === undefined) {
Expand Down
3 changes: 2 additions & 1 deletion src/instrumentation-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from '@sentry/nextjs'
import { sentryIgnoreErrors } from '@/utils/sentryIgnoreErrors'

const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN || process.env.SENTRY_DSN
const vercelEnv = process.env.NEXT_PUBLIC_VERCEL_ENV
Expand Down Expand Up @@ -33,7 +34,7 @@ if (dsn) {
// }),
],

ignoreErrors: [/fetch failed/i, /failed to fetch/i],
ignoreErrors: sentryIgnoreErrors,

beforeSend(event) {
if (!isProd && event.type === undefined) {
Expand Down
3 changes: 2 additions & 1 deletion src/jobs/sentry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'server-only'

import * as Sentry from '@sentry/nextjs'
import { sentryIgnoreErrors } from '@/utils/sentryIgnoreErrors'

// Trigger.dev runs jobs in a standalone Node process, separate from the Next.js server, so
// `sentry.server.config.ts` (loaded via instrumentation.ts) never executes here — without
Expand All @@ -17,7 +18,7 @@ if (dsn) {
// integration set (matches Trigger.dev's documented Sentry setup).
defaultIntegrations: false,
environment: process.env.SENTRY_ENVIRONMENT || process.env.NODE_ENV || 'development',
ignoreErrors: [/fetch failed/i],
ignoreErrors: sentryIgnoreErrors,
})
}

Expand Down
17 changes: 17 additions & 0 deletions src/utils/sentryIgnoreErrors.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { sentryIgnoreErrors } from './sentryIgnoreErrors'

const isIgnored = (message: string) => sentryIgnoreErrors.some((pattern) => pattern.test(message))

describe('sentryIgnoreErrors', () => {
it.each([
'retryable error: max retries exceeded',
'Unable to send replay - max retries exceeded',
'TypeError: fetch failed',
])('ignores known retry and network noise: %s', (message) => {
expect(isIgnored(message)).toBe(true)
})

it('does not ignore application errors', () => {
expect(isIgnored('Failed to perform a Copilot API call: {"code":"api_error"}')).toBe(false)
})
})
6 changes: 6 additions & 0 deletions src/utils/sentryIgnoreErrors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const sentryIgnoreErrors = [
/fetch failed/i,
/failed to fetch/i,
/retryable error: max retries exceeded/i,
/unable to send replay - max retries exceeded/i,
]
Loading