diff --git a/packages/nextjs/src/common/wrapRouteHandlerWithSentry.ts b/packages/nextjs/src/common/wrapRouteHandlerWithSentry.ts index 33ea97e5fe0c..a4d7a96b94fd 100644 --- a/packages/nextjs/src/common/wrapRouteHandlerWithSentry.ts +++ b/packages/nextjs/src/common/wrapRouteHandlerWithSentry.ts @@ -1,6 +1,7 @@ import { addTracingExtensions, captureException, flush, getCurrentHub, runWithAsyncContext, trace } from '@sentry/core'; import { addExceptionMechanism, tracingContextFromHeaders } from '@sentry/utils'; +import { isRedirectNavigationError } from './nextNavigationErrorUtils'; import type { RouteHandlerContext } from './types'; import { platformSupportsStreaming } from './utils/platformSupportsStreaming'; @@ -53,16 +54,19 @@ export function wrapRouteHandlerWithSentry any>( return response; }, error => { - captureException(error, scope => { - scope.addEventProcessor(event => { - addExceptionMechanism(event, { - handled: false, + // Next.js throws errors when calling `redirect()`. We don't wanna report these. + if (!isRedirectNavigationError(error)) { + captureException(error, scope => { + scope.addEventProcessor(event => { + addExceptionMechanism(event, { + handled: false, + }); + return event; }); - return event; - }); - return scope; - }); + return scope; + }); + } }, ); } finally {