Skip to content

Handling TRPC errors in SentryΒ #14004

@MonkeeMan1

Description

@MonkeeMan1

Environment

SaaS (https://sentry.io/)

What are you trying to accomplish?

Hello,

I have recently implemented Sentry into my webapp that uses TRPC. However, we are running into problems with Sentry displaying error pages to our users for client side errors which do not break functionality. See image below
Image

How are you getting stuck?

An example of when this page appears is when a user tries to visit a page which requires them to be signed in.
On our protectedProcedure function we check if the user is signed in, and if they aren't we throw a TRPC unauthorized error.

export const protectedProcedure = t.procedure.use(({ ctx, next }) => {
	if (!ctx.session || !ctx.session.user) {
		throw new TRPCError({ code: 'UNAUTHORIZED', message: 'You are not signed in' });
	}

This is resulting in the error below: Image

We are using an error boundary provided by sentry, with no props: import { ErrorBoundary } from '@sentry/nextjs'; and wrapping that inside of our root layout.

How would I go about stopping sentry from detecting these TRPC errors?

Where in the product are you?

Unknown

Link

No response

DSN

No response

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions