Skip to content

[nextjs] reactComponentAnnotation drops source-map names, so stack frames keep minified function names #26939

In review

Description

@MorrisonCole

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

11.19.0

Framework Version

Next 16.4.6, React 19.3.1

Link to Sentry event

No response

Reproduction Example/SDK Setup

https://github.com/MorrisonCole/sentry-component-annotation-sourcemap-names

export default withSentryConfig(nextConfig, {
  sourcemaps: { disable: true },
  reactComponentAnnotation: { enabled: process.env.ANNOTATE === '1' },
});

nextConfig sets only productionBrowserSourceMaps: true, so the maps can be read locally.

Steps to Reproduce

  1. Clone the repo and run npm install.
  2. Run npm run repro. It builds with webpack and with Turbopack, each with reactComponentAnnotation off and on.
  3. After each build, check-names.mjs prints the name on the source-map mapping of each function declared in app/login-button.tsx.

Expected Result

The mapping on each minified function binding keeps the original name, as it does with the option off. Sentry then shows handleLogin in stack frames.

Actual Result

With the option on, the mappings have no name, with both bundlers:

== next build --webpack, reactComponentAnnotation off
LoginButton    minified as o, mapping name: LoginButton
handleClick    minified as o, mapping name: handleClick
handleLogin    minified as n, mapping name: handleLogin
== next build --webpack, reactComponentAnnotation on
LoginButton    no mapping at the declaration
handleClick    no mapping at the declaration
handleLogin    minified as n, mapping name: null
== next build --turbopack, reactComponentAnnotation off
LoginButton    no mapping at the declaration
handleClick    minified as n, mapping name: handleClick
handleLogin    minified as a, mapping name: handleLogin
== next build --turbopack, reactComponentAnnotation on
LoginButton    no mapping at the declaration
handleClick    minified as a, mapping name: null
handleLogin    minified as i, mapping name: null

So stack frames from annotated files show minified function names (n, a, i), even though the files, lines and source context resolve. The minified names change from build to build. Grouping uses function names, so one error can split into a new issue on each release.

On a real app, our client chunk maps had 750 named and 776 unnamed function bindings with the option on, against 807 named and 590 unnamed with it off (Turbopack).

Additional Context

node transform.mjs in the repo calls createComponentNameAnnotateHooks from @sentry/bundler-plugins/loader-utils directly:

annotated: true
map.names: []

The transform edits the code with magic-string and returns magicString.generateMap({ hires: true }). That map has no names. I think the names are lost when the bundler composes this map with the later SWC and minifier maps, but I have not confirmed which step drops them.

The workaround is reactComponentAnnotation: { enabled: false }, at the cost of component names in breadcrumbs, Replay and spans.

Turbopack also drops some names on its own (vercel/next.js#102474), but only in modules that import another local module. The repro component has no local imports, so that bug does not apply here.

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Activity

  1. linear-code commented on Nov 27, 2026

    @linear-code
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Nov 27, 2026
  3. self-assigned this
    on Nov 27, 2026
  4. chargome commented on Nov 27, 2026

    @chargome
    Member

    Thanks for reporting @MorrisonCole !

  5. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions