Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
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
.

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:

Metadata
Metadata
Assignees
Type
Projects
Status
No status