Skip to content

Next.js middleware sourcemaps built to from .next/server/src missing #8646

@meyer9

Description

@meyer9

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

7.60.0

Framework Version

Next.js 13.4.9

Link to Sentry event

https://placepull.sentry.io/discover/mercury:343d9d59ead7441bb0f30872747d2b9a/?field=title&field=release&field=environment&field=user.display&field=timestamp&name=Error%3A+this+is+a+test+error+2&project=5662046&query=issue%3AMERCURY-8AN&sort=-timestamp&statsPeriod=90d&yAxis=count%28%29

SDK Setup

/**
 * @type {Partial<import("@sentry/nextjs").SentryWebpackPluginOptions>}
 */
const SentryWebpackPluginOptions = {
  deploy: SENTRY_ENABLED
    ? {
        env: SENTRY_ENV,
      }
    : undefined,
  release: NEXT_PUBLIC_COMMIT_SHA,
  env: SENTRY_ENV,
  authToken: SENTRY_AUTH_TOKEN,
  finalize: !SENTRY_ENABLED,
  dryRun: !SENTRY_ENABLED,
  hideSourceMaps: true,
  silent: NODE_ENV !== 'production',
}

Steps to Reproduce

  1. Trigger an error in NextJS middleware.
Error: this is a test error 2
    at Object.middleware$1 (file:///Users/work/development/app/.next/server/src/middleware.js:8544:15)
    at Object.<anonymous> (file:///Users/work/development/app/.next/server/src/middleware.js:8344:49)
    at Object.apply (file:///Users/work/development/app/.next/server/src/middleware.js:8424:16)
    at adapter (file:///Users/work/development/app/.next/server/src/middleware.js:1250:33)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
  1. Notice the stack trace in Sentry includes an error about absolute URLs

Expected Result

Source map should shows up in Sentry.

Actual Result

The abs_path of the stack frame is /Users/work/development/app/.next/server/src/middleware.js which is not a valid URL. Read our docs for troubleshooting help.

From this code: https://github.com/getsentry/sentry-javascript/blob/develop/packages/nextjs/src/config/webpack.ts#L627-L634

It seems like .next/server/src is not included.

Metadata

Metadata

Assignees

Labels

Package: nextjsIssues related to the Sentry Nextjs SDK

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions