question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@sentry/nextjs does not upload sourcemaps for "first load JS" files

See original GitHub issue

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/nextjs

SDK Version

7.3.0

Framework Version

7.3.0

Link to Sentry event

https://sentry.io/organizations/ravo-llc/issues/3385096554

Steps to Reproduce

The @sentry/nextjs integration seems to be skipping the upload of sourcemaps for NextJS JavaScript files that are categorized as “first load JS shared by all”, e.g.:

+ First Load JS shared by all              745 kB
  ├ chunks/framework-d36e54abd99436b9.js   45.1 kB
  ├ chunks/main-e4617a57cbc2ff7d.js        28.7 kB
  ├ chunks/pages/_app-ca156fce00b9bdf4.js  669 kB
  ├ chunks/webpack-14d0779d6a8c8953.js     2.33 kB

Therefore all error events that have the framework / main files in the stacktrace cannot be properly processed.

Reproduction Steps

  • Create a production build that also uploads source maps to Sentry
  • Trigger a frontend error event
  • Error event shows with obfuscated lines for “framework.js” stacktrace on Sentry. Also the following error message shows up:

2022-06-28_09-04

Expected Result

I checked, and source maps are generated for those “first load shared by all” JS files. I expect them to be uploaded to Sentry, too

Actual Result

Source maps for framework.js, app.js, main.js etc. are not uploaded

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
michaelschuficommented, Aug 22, 2022

I’m experiencing the same issue. But I don’t think it actually matters that much, in the end it’s just visually wrong. Let me explain.

Workaround

Before I explain, why I think it’s not a huge issue, the workaround, which solved the problem.

As @varun-raj suggested, setting the ignore option to an empty array works. I made those changes:

// NextConfig
sentry: {
  widenClientFileUpload: true,
},

// SentryWebpackPluginOptions
{
  ignore: [],
}

Explanation and Thoughts

When Sentry is processing the event, it tries to get the source maps from the release archive the error event is connected to. Since the change @varun-raj mentioned, the framework’s code does not get uploaded by default anymore. This means that Sentry can’t find all the files to completely resolve stack trace.

But: The user code is still uploaded, so everything that’s specific to your project, can still be resolved.

As you can see in the following screenshot: the topmost part looks clean, and it’s clear where the error occurred.

However, it’s definitely a step back from the clear and concise view we get if all the sources can be resolved:

frontend_error_ignore_empty

I understand that it’s in everyone’s interest to reduce unnecessary uploading of source maps. But it’s annoying to scroll through all the unnecessary framework stack trace part to reach the Breadcrumbs section in the issue view.

Note

I want to mention one thing that confused me about all of this. It’s the following processing error I get.

frontend_error_message

This occurs if the source file cannot be found, Sentry tries to access it (but it’s inaccessible because it’s a private page). In my opinion, it makes you troubleshoot in the wrong direction. Being new to Sentry, it’s weird to get such an error if you’re just using defaults everywhere. I first thought my config was wrong, the security settings were wrong, etc. until I read up on how it actually works. It would help to have some exceptions or a note if the event came from the Next.js SDK.

0reactions
tiguchicommented, Jul 24, 2022

Here is a comment for the stale bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Source Maps for Next.js
In case the source map files do not contain your original source code ... To add a dist value to your uploaded source...
Read more >
What is the recommended approach to upload source maps to ...
js as can be read here. I am wondering what the correct (best-practice) approach is for uploading/providing source maps to sentry when deploying ......
Read more >
Configuring Sentry with JavaScript Source Maps
An epic troubleshooting tale to enable JavaScript source map fetching in Sentry.
Read more >
Blog - Next.js 11.1
The reported issue did not directly harm users, but it could allow ... performance of uploading source maps with the Sentry Next.js plugin....
Read more >
Troubleshooting for React | Sentry Documentation
js ) and the corresponding source maps. In case the source map files do not contain your original source code ( sourcesContent ),...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found