Skip to content

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

Closed
@Lms24

Description

@Lms24

The incorrect behaviour seems to be present in @sentry/[email protected] - 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)

Metadata

Metadata

Assignees

Labels

Package: sveltekitIssues related to the Sentry SvelteKit SDK

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions