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

Every issue has DELETE,GET,HEAD,PATCH,POST,PUT,OPTIONS,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,TRACE,SEARCH #14013

Open
3 tasks done
divmgl opened this issue Oct 17, 2024 · 3 comments
Labels
Package: node Issues related to the Sentry Node SDK

Comments

@divmgl
Copy link

divmgl commented Oct 17, 2024

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.34.0

Framework Version

No response

Link to Sentry event

https://permitflow.sentry.io/issues/5999574154/?environment=prod&project=4504595707396096&query=is%3Aunresolved%20issue.priority%3A%5Bhigh%2C%20medium%5D&referrer=issue-stream&statsPeriod=1h&stream_index=0

Reproduction Example/SDK Setup

const server = Fastify({
      maxParamLength: 15000,
      trustProxy: true,
      logger: {
        enabled: CONFIGURATION.verbose,
        transport: { target: "pino-pretty" },
      },
    })

    Sentry.setupFastifyErrorHandler(server)
const sentryMiddleware = t.middleware(Sentry.trpcMiddleware({ attachRpcInput: true }))
import * as Sentry from "@sentry/node"
import { nodeProfilingIntegration } from "@sentry/profiling-node"

const isProduction = process.env.NODE_ENV === "production"
const dsn = process.env.SENTRY_DSN

Sentry.init({
  environment: isProduction ? "prod" : "dev",
  enabled: isProduction,
  debug: false,
  dsn: dsn,
  integrations: [
    nodeProfilingIntegration(),
    Sentry.httpIntegration(),
    Sentry.prismaIntegration(),
    Sentry.fastifyIntegration(),
  ],
  tracesSampleRate: 0.05,
  profilesSampleRate: 1.0, // This is relative to tracesSampleRate
  ignoreErrors: [
    "User does not have permission",
    "User is not a member of this workspace",
    /^No .* found$/,
    /BAD_REQUEST|TOO_MANY_REQUESTS|UNAUTHORIZED|FORBIDDEN|NOT_FOUND/,
  ],
})

Steps to Reproduce

I'm not sure how else to specify this. I installed the latest verison, and set it up as per the docs and I'm getting this spam.

Expected Result

The error messages are preserved.

Actual Result

Image

I get DELETE,GET,HEAD,PATCH,POST,PUT,OPTIONS,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK,TRACE,SEARCH /trpc/:path on almost every Sentry issue...

@github-actions github-actions bot added the Package: node Issues related to the Sentry Node SDK label Oct 17, 2024
@chargome
Copy link
Member

Hi @divmgl thanks for reaching out.

First thing, since you're on v8 you can get rid of Sentry.httpIntegration() (it's enabled by default) and Sentry.fastifyIntegration() (not needed anmore for the Fastify setup).

Do you have any special errorFormatter logic in your trpc initialization?

@divmgl
Copy link
Author

divmgl commented Oct 18, 2024

@chargome btw, removing Sentry.setupFastifyErrorHandler(server) fixed the issue for us.

We do have a special error formatter.

export const t = initTRPC
  .meta<OpenApiMeta>()
  .context<TRPCContext>()
  .create({
    transformer: superjson,
    errorFormatter({ shape, error }) {
      const isNotFoundError =
        error.cause &&
        error.cause instanceof PrismaClientKnownRequestError &&
        error.cause.code === "P2025"

      const message = handleBadRequestErrors(error)

      if (isNotFoundError) {
        return merge(shape, {
          data: {
            code: "NOT_FOUND",
            httpStatus: 404,
            stack: error.stack,
          },
        }) satisfies DefaultErrorShape
      } else if (message) {
        return merge(shape, {
          message,
          code: TRPC_ERROR_CODES_BY_KEY.BAD_REQUEST,
          data: {
            code: "BAD_REQUEST",
            httpStatus: 400,
            stack: error.stack,
          },
        }) satisfies DefaultErrorShape
      }

      return shape
    },
  })

Nothing too crazy.

@s1gr1d
Copy link
Member

s1gr1d commented Oct 21, 2024

Good to hear that you could fix that issue by removing setupFastifyErrorHandler 🙌 Do you still face issues or can this be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: node Issues related to the Sentry Node SDK
Projects
Status: No status
Development

No branches or pull requests

3 participants