Skip to content

SvelteKit redirects thrown in instrumented load functions should not trigger captureException #7719

Closed
@ncvc

Description

@ncvc

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using? If you use the CDN bundles, please specify the exact bundle (e.g. bundle.tracing.min.js) in your SDK setup.

@sentry/sveltekit

SDK Version

7.46.0

Framework Version

1.14.0

Link to Sentry event

https://agent-tax.sentry.io/issues/4060190821/events/bb31c59cd19e4408b51221e4a4a1904b/?project=6229544

SDK Setup

No response

Steps to Reproduce

Instrument a Sveltekit load function in a +page.ts file with wrapLoadWithSentry, and throw a redirect.

For instance:

import { wrapLoadWithSentry } from "@sentry/sveltekit";
import { redirect } from "@sveltejs/kit";

import type { PageLoad } from "./$types";

export const load: PageLoad = wrapLoadWithSentry(async () => {
  throw redirect(302, "/some/other/path");
});

Expected Result

redirect errors thrown from load functions should not create a new issue in sentry, since this is just a control flow mechanism in load functions to return a redirect.

It looks like this can be ignored in the same place sentry is ignoring 4xx errors on the server side:

if (isHttpError(objectifiedErr) && objectifiedErr.status < 500 && objectifiedErr.status >= 400) {

And I believe there should be similar logic in the client side as well:

const objectifiedErr = objectify(e);

Actual Result

A new issue is created when a redirect error is thrown in a load function

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