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 Sentry handler clobbers error messages in dev #15428

Open
3 tasks done
divmgl opened this issue Feb 16, 2025 · 3 comments
Open
3 tasks done

Sveltekit Sentry handler clobbers error messages in dev #15428

divmgl opened this issue Feb 16, 2025 · 3 comments
Assignees
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK

Comments

@divmgl
Copy link

divmgl commented Feb 16, 2025

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/svelte

SDK Version

"@sentry/sveltekit": "^8",

Framework Version

Svelte 5

Link to Sentry event

No response

Reproduction Example/SDK Setup

Instrumenting Sveltekit results in error messages being clobbered in local dev. This means that I have to deploy different versions of my codebase to production than what's in development, which is not ideal. This happens even if Sentry is not enabled:

Sentry.init({
  dsn: /** DSN omitted */
  tracesSampleRate: 1,
  enabled: import.meta.env.PROD,
  environment: import.meta.env.PROD ? "prod" : "dev",
})


export const handle: Handle = sequence(Sentry.sentryHandle(), sequence(supabase, authGuard))
export const handleError = Sentry.handleErrorWithSentry()

Any error occurs on a +page.server.ts module, undefined gets printed to console rather than the actual error. It's happening with every error.

Steps to Reproduce

export const handle: Handle = sequence(Sentry.sentryHandle(), sequence(supabase, authGuard))
export const handleError = Sentry.handleErrorWithSentry()

Expected Result

Image

Actual Result

Image

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Feb 16, 2025
@github-actions github-actions bot added the Package: svelte Issues related to the Sentry Svelte SDK label Feb 16, 2025
@divmgl
Copy link
Author

divmgl commented Feb 16, 2025

I've narrowed it down to this:

export const handleError = Sentry.handleErrorWithSentry()

@divmgl
Copy link
Author

divmgl commented Feb 16, 2025

I was able to solve it like this:

const sentryHandleError = Sentry.handleErrorWithSentry()

export const handleError: HandleServerError = (props) => {
  if (import.meta.env.PROD) {
    return sentryHandleError(props)
  }

  console.error(props.error)
}

Still, not ideal.

@Lms24
Copy link
Member

Lms24 commented Feb 17, 2025

Hi @divmgl thanks for writing in! Before I try to reproduce this, did you follow our setup guide? It tells you to pass your error handler (where you print to the console) as a callback to Sentry.handleErrorWithSentry(). Let me know if this changes anything, thanks :)

@Lms24 Lms24 self-assigned this Feb 17, 2025
@Lms24 Lms24 added Package: sveltekit Issues related to the Sentry SvelteKit SDK and removed Package: svelte Issues related to the Sentry Svelte SDK labels Feb 17, 2025
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
Projects
Status: No status
Development

No branches or pull requests

2 participants