Skip to main content

[Next.js] Why am I not receiving server errors?

Issue

I receive Sentry events from my Next.js client and edge configs, but server-thrown errors do not appear in Sentry.

Applies To

  • All SaaS Customers and Self-Hosted Users

  • Next.js SDK

  • Error Monitoring

Resolution

@sentry/nextjs initializes separately per runtime. sentry.server.config.ts runs only in the Node.js runtime. Client and edge configs do not cover Node server code.

  1. Confirm the failing code runs on the Node.js runtime. If the route or Server Component sets runtime = "edge", Sentry uses sentry.edge.config.ts, not the server config. Move the work to Node, or configure and test the edge SDK path instead.

  2. Confirm instrumentation.ts loads the server config when process.env.NEXT_RUNTIME === "nodejs", and that sentry.server.config.ts calls Sentry.init with your DSN.

  3. For Next.js 15+ with @sentry/nextjs 8.28.0 or newer, export onRequestError = Sentry.captureRequestError from instrumentation.ts so Server Components, middleware, and proxies report errors.

  4. If you catch errors in error.tsx, API routes, or Server Actions and do not rethrow, call Sentry.captureException yourself. Next.js error boundaries and graceful try/catch hide errors from the global handler.

Example instrumentation.ts shape:

import * as Sentry from "@sentry/nextjs";export async function register() {
  if (process.env.NEXT_RUNTIME === "nodejs") {
    await import("./sentry.server.config");
  }
  if (process.env.NEXT_RUNTIME === "edge") {
    await import("./sentry.edge.config");
  }
}export const onRequestError = Sentry.captureRequestError;

See the Next.js setup guide and capturing errors for full details.

Did this answer your question?