Skip to content

@sentry/nextjs v8 does not create issue/error on vercel for API Route Handler #12045

Description

@TuanManhCao

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

8.0.0

Framework Version

nextjs ^14.2.3

Link to Sentry event

No response

SDK Setup

// My setup is in src/instrumentation.ts
import * as Sentry from '@sentry/nextjs'
export async function register() {
  
  const SENTRY_DSN = process.env.SENTRY_DSN ?? process.env.NEXT_PUBLIC_SENTRY_DSN
  console.log('🚀 ~ register ~ register:', SENTRY_DSN)
  Sentry.init({
    dsn: "https://aaabbbccc@dddeeerrr.ingest.us.sentry.io/somenumber",

    // Adjust this value in production, or use tracesSampler for greater control
    tracesSampleRate: 1,

    // Setting this option to true will print useful information to the console while you're setting up Sentry.
    debug: false

    // uncomment the line below to enable Spotlight (https://spotlightjs.com)
    // spotlight: process.env.NODE_ENV === 'development',
  })
}

my nextjs config

const { withSentryConfig } = require("@sentry/nextjs");
/** @type {import('next').NextConfig} */
const nextConfig = {
  images : {
    // my nextjs config...
  }  
}

module.exports = withSentryConfig(
  nextConfig,
  {
    org: "my-org",
    project: "my-project",

    authToken: process.env.SENTRY_AUTH_TOKEN,
    
  }
);
   // src/app/api/sentry-example-api/route.ts
import { NextResponse, NextRequest } from "next/server";

export const dynamic = "force-dynamic";

// A faulty API route to test Sentry's error monitoring

export async function GET(request: NextRequest, response: NextResponse) {
  
  throw new Error("Sentry Example API Route Error");
  return NextResponse.json({ data: "Testing Sentry Error..." });
}

Steps to Reproduce

When i visit /api/sentry-example-api on localhost I see the error is tracked correctly in my sentry's dashboard's issues

However when I deployed the code to vercel cloud, I checked that the source map is uploaded correctly, the env variable for dsn, auth_token, all setup correctly (via console.log())

Step to reproduce:

  • When I visited the /api/sentry-example-api I saw the page show 500 error, checked vercel log, it does thow the error
  • But I cannot see the error show up in sentry's issue dashboard

cleanshot-2024-05-15-000328@2x

All work well in local env.

And strange thing is the client code for tracking error is working, meaning this page (see screenshot)
cleanshot-2024-05-15-000329@2x

Any idea?

Expected Result

The error for API route should show up in sentry dashboard

Actual Result

Right now the error does not show up in sentry dashboard

cleanshot-2024-05-15-000330@2x

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions