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

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

Closed
3 tasks done
meyer9 opened this issue Jul 26, 2023 · 1 comment · Fixed by #9454
Closed
3 tasks done

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

meyer9 opened this issue Jul 26, 2023 · 1 comment · Fixed by #9454
Assignees
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Bug

Comments

@meyer9
Copy link

meyer9 commented Jul 26, 2023

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.

@github-actions github-actions bot added the Package: nextjs Issues related to the Sentry Nextjs SDK label Jul 26, 2023
@meyer9 meyer9 changed the title Sentry Webpack configuration on Next.js 13.4.9 does not handle absolute URLs correctly Next.js middleware sourcemaps built to from .next/server/src missing Jul 26, 2023
@Lms24
Copy link
Member

Lms24 commented Jul 27, 2023

Hi @meyer9 thanks for writing in and for investigating! I believe your suspicion might be correct but I'm lacking context around NextJS middleware so I'm not sure if there are other things to consider. Since you've already come so far in debugging this, you could give adding the missing directory a try (for instance by directly modifying the file in your node modules or by cloning the repo) and see if it resolves the issue for you. Regardless though, we need to investigate this.

@lforst - when you're back, mind taking a look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants