Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Lms24 opened this issue May 25, 2023 · 1 comment · Fixed by #8215
Assignees
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK Type: Bug

Comments

@Lms24
Copy link
Member

Lms24 commented May 25, 2023

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)

@Lms24
Copy link
Member Author

Lms24 commented May 25, 2023

Hi @abirtley, thank you for reporting!

I've extracted this to a separate issue because we didn't handle this correctly in handle request handlers but only in load functions.

We should apply the same fix as in #7731 just for request handlers. I'll open a PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK Type: Bug
Projects
None yet
1 participant