Skip to content

fix(react-router): prevent unstable_sentryVitePluginOptions spread from overwriting sourcemaps - #22930

Closed
okxint wants to merge 1 commit into
getsentry:developfrom
okxint:fix/react-router-sourcemaps-spread-overwrite
Closed

fix(react-router): prevent unstable_sentryVitePluginOptions spread from overwriting sourcemaps#22930
okxint wants to merge 1 commit into
getsentry:developfrom
okxint:fix/react-router-sourcemaps-spread-overwrite

Conversation

@okxint

@okxint okxint commented Aug 1, 2026

Copy link
Copy Markdown

makeCustomSentryVitePlugins builds a sourcemaps: { disable: true, ...user } object to prevent double debug-ID injection during the React Router build. However, the trailing ...unstable_sentryVitePluginOptions spread on the next line overwrites the entire sourcemaps key with the user's raw value, dropping disable: true.

JavaScript's object spread is shallow — when both sourcemaps: { disable: true, ...userSourcemaps } and ...unstable_sentryVitePluginOptions are present on the same level, the second sourcemaps key wins unconditionally.

Fix: destructure sourcemaps out of unstable_sentryVitePluginOptions before the call, then use userSourcemaps inside the already-merged object and spread the remainder separately. This keeps user customizations on all other keys while preserving disable: true.

Fixes #22929

@chargome

chargome commented Aug 3, 2026

Copy link
Copy Markdown
Member

hey @okxint thanks for opening a pr! I'll tackle this in #22945 as I still need to add test coverage and handle some other test cases there.

@chargome chargome closed this Aug 3, 2026
chargome added a commit that referenced this pull request Aug 3, 2026
…yVitePluginOptions` is set (#22945)

A trailing `...unstable_sentryVitePluginOptions` spread sat after
`sourcemaps: { disable: true }`, and object spread replaces whole keys
rather than deep-merging — so any user-supplied `sourcemaps` object
dropped `disable`. The Vite plugin then injected a second debug ID on
top of the one from `sentryOnBuildEnd`.

The spread now sits between the plain options and the field-wise merged
objects: it can still<br>override flat keys (its documented contract)
but can't replace `sourcemaps`, `release`, `_metaOptions` or
`reactComponentAnnotation`.

supersedes
[#22930](<#22930>)
— credit to @okxint for the same diagnosis.

closes #22929

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[react-router] Any unstable_sentryVitePluginOptions.sourcemaps value re-enables double debug ID injection (regression of #19874)

2 participants