Skip to content

'Redirect' captured as exception with keys: location, status #16847

Description

@RaniSputnik

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/sveltekit

SDK Version

9.35.0

Framework Version

Sveltekit 2.17.1

Link to Sentry event

No response

Reproduction Example/SDK Setup

RaniSputnik/sentry-issues@redirect-captured-as-exception

Steps to Reproduce

Redirect using the Sveltekit server handle hook. Eg.

import { sequence } from '@sveltejs/kit/hooks';
import { handleErrorWithSentry, sentryHandle, initCloudflareSentryHandle } from '@sentry/sveltekit';
import { redirect, type Handle } from '@sveltejs/kit';

const redirectToSentryPage: Handle = async ({ event, resolve }): Promise<Response> => {
	if (!event.request.url.includes("sentry")) {
		return redirect(303, "sentry-example-page");
	}
	return resolve(event)
}


// If you have custom handlers, make sure to place them after `sentryHandle()` in the `sequence` function.
export const handle = sequence(
	initCloudflareSentryHandle({ /* dsn etc */ }),
	sentryHandle(),
	redirectToSentryPage,
);

// If you have a custom error handler, pass it to `handleErrorWithSentry`
export const handleError = handleErrorWithSentry();

Deploy to Cloudflare workers. (I haven’t tested whether this impacts other adaptors eg. Vercel)

Visit a page that triggers a redirect (eg. /foo in my example repo).

Expected Result

No error is captured by Sentry.

Actual Result

An error is captured by Sentry with the message 'Redirect' captured as exception with keys: location, status.

Image

It also seems like the issue fingerprint is changed by the path of the user and exactly when the redirect was raised, so this ends up having quite a large impact on our production instance. Multiple issues are opened for the same root cause:

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions