getsentry / sentry-netlify-build-plugin

The Sentry Netlify build plugin automatically notifies Sentry of new releases being deployed to your site.
Apache License 2.0
46 stars 17 forks source link

source maps have the incorrect path, need different option #67

Open flowen opened 1 year ago

flowen commented 1 year ago

Environment

7.12.1

Steps to Reproduce

We just can't get the sourcemaps to work: It's a next.js app running on netlify.

I've been going through the sentry sourcemaps walkthrough: https://docs.sentry.io/platforms/javascript/guides/nextjs/sourcemaps/troubleshooting_js/

There's a couple of suspect things, but I can't pinpoint the bottle-neck.

  1. There's no distribution version appointed to any of the artifacts, could that be problematic? (not sure how it lines up with sentry errors). An issue about this had been created in May https://github.com/getsentry/sentry-netlify-build-plugin/issues/60
  2. The result from sentry-cli sourcemaps explain dd8595f782254540987a1b49d12e2155 --org $ORG --project $OURPROJECT is
    [frontend] sentry-cli sourcemaps explain dd8595f782254540987a1b49d12e2155 --org hifi-labs --project musicos-alpha
    ✔ Fetched data for event: dd8595f782254540987a1b49d12e2155
    ✔ Event has release name: 22faee120328fe1cc486aaf1a0c0608628ae0a48
    ✔ Event has a valid exception present
    ✔ Event has a valid stacktrace present
    ✖ Uploaded artifacts do not include entry: ~/_next/static/chunks/framework-0ba0ddd33199226d.js
    ℹ Found entry with partially matching filename: ~/static/chunks/framework-0ba0ddd33199226d.js. Make sure that that --url-prefix is set correctly.

There's a sourceMapUrlPrefix option but it, as it says, prefixes the URL and we end up with ~/$PREFIX/_next/static/chunks/framework-0ba0ddd33199226d.js. I'm not sure what the word is, but we need to subtract part of the path.

The artifact entries in Sentry confirm the paths image

shanamatthews commented 1 year ago

Copying in a comment from one of the engineers at Netlify:

I took a quick look at this and unfortunately I haven't seen this error before, and I wasn't able to find something indicating NextJS had changed how source maps are handled recently that might have caused this.

I'm not the most familiar with the codebase for the existing netlify build plugin for Sentry, but my initial instinct is this might have something to do with how the NextJS routing works and it's not playing nice with what the plugin/Sentry is expecting.

Because NextJS outputs source file maps in the same place as the source code, the 'partially matching filename' mentioned in the Github issue:

~/static/chunks/framework-0ba0ddd33199226d.js

is where the source map correctly lives if we were looking in the file explorer and the missing artifact entry:

 ~/_next/static/chunks/framework-0ba0ddd33199226d.js

is what I would expect to see as a route if I was trying to navigate to that page in the browser and was looking at the request for that page network tab.