Skip to content

Sentry Sveltekit does not respect "myErrorHandler"Β #13669

@alexbjorlig

Description

@alexbjorlig

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/sveltekit

SDK Version

"@sentry/sveltekit": "^8.30.0"

Framework Version

"@sveltejs/kit": "^2.5.26",

Link to Sentry event

No response

Reproduction Example/SDK Setup

This setup:

import { sequence } from "@sveltejs/kit/hooks";
import { sentryHandle } from "@sentry/sveltekit";
import type { HandleServerError } from "@sveltejs/kit";
import * as Sentry from "@sentry/sveltekit";

Sentry.init({
  dsn: "dsn",
  tracesSampleRate: 1.0,
  beforeSend(event, hint) {

    console.warn(`🟑Why is Sentry's beforeSend hook is running 🟑`);
    return null;
  },
});

// If you have custom handlers, make sure to place them after `sentryHandle()` in the `sequence` function.
export const handle = sequence(sentryHandle());

const myErrorHandler: HandleServerError = ({}) => {
  console.log('Lets ignore error - i.e. we are NOT reporting');
  return;
};

export const handleError = Sentry.handleErrorWithSentry(myErrorHandler);

ALWAYS report, i.e. the beforeSend always run.

Steps to Reproduce

  1. Clone repo here
  2. Start dev server with npm run dev
  3. Make an error appear: curl http://localhost:5173 test-route -X POST
Sentyr.bug.in.sveltekit.mp4

Expected Result

beforeSend should not fire, because we don't report the error in myErrorHandler.

Actual Result

beforeSend does actually fire!

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPackage: svelteIssues related to the Sentry Svelte SDK

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions