Skip to main content

[Next.js] Why aren't frames from static/chunks source mapped?

Issue

Stack frames from my Next.js app under static/chunks/ stay minified in Sentry. Other frames source-map correctly. I want readable file names and line numbers for those static/chunks/ frames.

Applies To

  • All SaaS Customers and Self-Hosted Users

  • Next.js SDK

  • Source Maps

  • Error Monitoring

Resolution

Client frames under static/chunks/ stay unmapped because the Next.js SDK does not upload those files by default. Set widenClientFileUpload to true in withSentryConfig.

By default the SDK uploads client source maps from static/chunks/pages/ and static/chunks/app/. Other files under static/chunks/ are skipped. Enable widenClientFileUpload to include those extra client chunks, including maps from third-party packages.

  1. Add widenClientFileUpload: true to withSentryConfig in your Next.js config file (next.config.js, next.config.mjs, or next.config.ts):

    export default withSentryConfig(nextConfig, {
      widenClientFileUpload: true,
    });
  2. Run a production rebuild so the SDK can upload the wider set of source maps.

  3. Trigger a new event. Source maps apply to events captured after the upload, not to older events.

Enabling widenClientFileUpload increases build time. See widenClientFileUpload.

If frames are still unmapped after you set widenClientFileUpload:

The SDK still skips Next.js internal chunks such as framework*, polyfills*, and webpack*. Follow Why are static/chunks frames still unmapped after widenClientFileUpload?.

Did this answer your question?