Skip to content

[NextJS] No data being sent from server-side functions #17193

@cbovis

Description

@cbovis

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

9.42.1

Framework Version

NextJS 15.4.4

Link to Sentry event

No response

Reproduction Example/SDK Setup

I've set up a repo with an app that reproduces the problem consistently: https://github.com/cbovis/nextjs-sentry-server-bug. The repo just contains a template NextJS app with most of the set up instructions from https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ applied to it.

An API route exists which calls logger.info and then throws an error. On the app's homepage there's a "break the world" button which calls that endpoint as per the verify step of the setup guide (https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#step-8-verify). The homepage also calls logger.info.

It's configured with a real DSN which hopefully the Sentry team can view the associated data of.

The reproduction is only broken when deployed to Vercel (standard configuration). When running locally data gets sent to Sentry as expected from both client and server code.

When running locally with debug enabled I see that Sentry flushes data a little while after the API request completes. I'm wondering if this issue is only see in Vercel because of the serverless environment being destroyed before flushing happens. NextJS has an after function for scheduling work after a request is finished (https://nextjs.org/docs/app/api-reference/functions/after). Perhaps this isn't being used?

Steps to Reproduce

Hosted at https://nextjs-sentry-server-bug.vercel.app/ for convenience.

  1. Hit the homepage of the app and click the button.
  2. Access the API route manually for good measure (https://nextjs-sentry-server-bug.vercel.app/api/sentry-example-api)

Expected Result

Expect to see logging and errors in the associated Sentry account for production environment. Also expect to see both frontend/backend transactions and spans.

Actual Result

Only logging, errors, transactions, and spans are stored for client-side code, not server-side code.

Metadata

Metadata

Assignees

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions