Skip to content

SvelteKit redirects thrown in instrumented request handlers should not trigger captureException #8214

Description

@Lms24

The incorrect behaviour seems to be present in @sentry/sveltekit@7.52.1 - after following the setup instructions, with a pretty vanilla SvelteKit application, redirects from within the server hooks handle() function are being reported to Sentry as errors. Or rather, we see the following error since a SvelteKit redirect is not an instance of class Error:

Object.captureException
💀 Unhandled Non-Error exception captured with keys: location, status

A minimal reproduction would be something like this:

// hooks.server.ts
export const handle = async ({ event, resolve }) => {
// dummy logic to handle users who aren't logged in
if (event.url.pathname !== '/login') {
throw redirect(303, '/login');
}
const response = await resolve(event);
return response;
};

Originally posted by @abirtley in #7719 (comment)

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions