Title: [react-router] Any `unstable_sentryVitePluginOptions.sourcemaps` value re-enables double debug ID injection (regression of #19874) · Issue #22929 · getsentry/sentry-javascript · GitHub
Open Graph Title: [react-router] Any `unstable_sentryVitePluginOptions.sourcemaps` value re-enables double debug ID injection (regression of #19874) · Issue #22929 · getsentry/sentry-javascript
X Title: [react-router] Any `unstable_sentryVitePluginOptions.sourcemaps` value re-enables double debug ID injection (regression of #19874) · Issue #22929 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues I have reviewed the documentation I am using the latest SDK release How do you use Sentry? Sentry Saas (sentry.io) Which SDK are you using? @sentry/react-router SDK ...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues I have reviewed the documentation I am using the latest SDK release How do you use Sentry? Sentry Saas (sentry.io) Which SDK ...
X Description: Is there an existing issue for this? I have checked for existing issues I have reviewed the documentation I am using the latest SDK release How do you use Sentry? Sentry Saas (sentry.io) Which SDK ...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/22929
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[react-router] Any `unstable_sentryVitePluginOptions.sourcemaps` value re-enables double debug ID injection (regression of #19874)","articleBody":"## Is there an existing issue for this?\n\n- [X] I have checked for existing issues\n- [X] I have reviewed the documentation\n- [X] I am using the latest SDK release\n\n## How do you use Sentry?\n\nSentry Saas ([sentry.io](\u003chttp://sentry.io>))\n\n## Which SDK are you using?\n\n`@sentry/react-router`\n\n## SDK Version\n\n10.56.0\n\n## Framework Version\n\nReact Router 7.17.0\n\n## Link to Sentry event\n\nN/A\n\n## Reproduction Example/SDK Setup\n\n`#19890` fixed the double debug ID injection in getsentry/sentry-javascript#19874 by setting `sourcemaps: { disable: true }` on the underlying Vite plugin. That fix is bypassed by a trailing spread in the same object literal, so **any** user who passes a `sourcemaps` key through `unstable_sentryVitePluginOptions` lands back in the exact failure mode of getsentry/sentry-javascript#19874 — on current versions.\n\n`makeCustomSentryVitePlugins.ts`, unchanged on `main` today:\n\n```ts\nconst sentryVitePlugins = sentryVitePlugin({\n // ...\n release: {\n ...unstable_sentryVitePluginOptions?.release,\n ...release,\n },\n // will be handled in buildEnd hook\n sourcemaps: {\n disable: true,\n ...unstable_sentryVitePluginOptions?.sourcemaps,\n },\n ...unstable_sentryVitePluginOptions, // \u003c-- re-assigns `sourcemaps` wholesale\n})\n```\n\nThe inner merge is fine — it preserves `disable: true` unless the user explicitly sets `sourcemaps.disable`. The trailing `...unstable_sentryVitePluginOptions` then replaces the whole `sourcemaps` **key** with the user's raw object, dropping `disable` entirely. Object spread replaces at the top level; it does not deep-merge.\n\n`disable` is then absent → `undefined`, and the gate in `@sentry/rollup-plugin` is a strict comparison:\n\n```js\nconst sourcemapsEnabled = options.sourcemaps?.disable !== true; // undefined !== true\n// ...\nif (sourcemapsEnabled && !hasExistingDebugID(code)) {\n const debugId = stringToUUID(code);\n injectCode.append(getDebugIdSnippet(debugId));\n}\n```\n\nSo the Vite plugin injects debug IDs again, and getsentry/sentry-javascript#19874's chain replays in full.\n\nThe config that triggers it is not exotic — this is the shape [epic-stack](\u003chttps://github.com/epicweb-dev/epic-stack/blob/main/vite.config.ts>) ships, and it's a widely-copied React Router 7 starter:\n\n```ts\nconst sentryConfig: SentryReactRouterBuildOptions = {\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: process.env.SENTRY_ORG,\n project: process.env.SENTRY_PROJECT,\n\n unstable_sentryVitePluginOptions: {\n release: { name: process.env.COMMIT_SHA, setCommits: { auto: true } },\n sourcemaps: {\n filesToDeleteAfterUpload: ['./build/**/*.map'], // \u003c-- enough to trigger it\n },\n },\n}\n```\n\n## Steps to Reproduce\n\nThe grep repro from getsentry/sentry-javascript#19874 reproduces this too, with `sourcemaps.filesToDeleteAfterUpload` added to `unstable_sentryVitePluginOptions`:\n\n```bash\nSENTRY_AUTH_TOKEN=fake npx react-router build\ngrep -oE '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}' \\\n build/client/assets/entry.client-*.js | sort | uniq -c\n```\n\n→ two different UUIDs in one file.\n\nIsolating it from the build, driving `makeCustomSentryVitePlugins` directly and running `renderChunk` over a sample chunk (`@sentry/react-router@10.56.0`, `@sentry/rollup-plugin@5.3.0`):\n\n```js\nconst { makeCustomSentryVitePlugins } =\n require('@sentry/react-router/build/cjs/vite/makeCustomSentryVitePlugins.js')\n\nconst SAMPLE = '\"use strict\";\\nconsole.log(\"hello from a chunk\");\\n'\n\nconst run = async (label, options) => {\n const plugins = await makeCustomSentryVitePlugins(options)\n let injected = 0\n for (const p of plugins) {\n if (typeof p.renderChunk !== 'function') continue\n const out = await p.renderChunk.call(p, SAMPLE,\n { fileName: 'entry.client-abc123.js', facadeModuleId: '/app/entry.client.tsx' }, {}, {})\n const code = typeof out?.code === 'string' ? out.code : (out?.code?.toString?.() ?? '')\n injected += (code.match(/_sentryDebugIds\\[[^\\]]+\\]\\s*=\\s*\"([0-9a-f-]{36})\"/g) || []).length\n }\n console.log(label, '->', injected)\n}\n```\n\nResults:\n\n```\n=== epic-stack config (sourcemaps inside unstable_) ===\nresolved sourcemaps option : {\"filesToDeleteAfterUpload\":[\"./build/**/*.map\"]}\nsourcemaps.disable : undefined\ndebug ids injected by plugin: 1 \u003c-- should be 0\n\n=== top-level fields only ===\nresolved sourcemaps option : {\"disable\":true}\nsourcemaps.disable : true\ndebug ids injected by plugin: 0\n\n=== workaround from #19874 (sourcemaps.disable: true in unstable_) ===\nresolved sourcemaps option : {\"disable\":true,\"filesToDeleteAfterUpload\":[\"./build/**/*.map\"]}\nsourcemaps.disable : true\ndebug ids injected by plugin: 0\n```\n\n## Expected Result\n\n`sourcemaps.disable = true` — which the react-router integration sets deliberately, since injection and upload are handled by `sentryOnBuildEnd` — should not be silently discarded by passing an unrelated key such as `filesToDeleteAfterUpload`. Each chunk should carry exactly one debug ID, matching the uploaded artifact.\n\n## Actual Result\n\nTwo debug IDs per chunk, and the one that wins at runtime is guaranteed to be the one Sentry has no artifact for:\n\n1. **Client build** — the Vite plugin injects debug ID **A**, uploads chunks + maps under A, then its `finally` runs `deleteArtifacts()` against the user's `filesToDeleteAfterUpload` glob and deletes every client `.map`.\n2. `buildEnd` — `sentryOnBuildEnd` runs `sentry-cli sourcemaps inject \u003cbuildDirectory>`. It finds chunks with no adjacent `.map`, so it appends a second debug ID **B**, with no map to write it into and none to upload.\n3. **Runtime** — both snippets execute. They sit at different lines, so they produce different `new Error().stack` keys and **both** entries live in `_sentryDebugIds`. `applyDebugIds` then flattens that to filename → debugId, and since both stacks resolve to the same filename, the later insertion wins. The CLI's snippet is at the bottom of the file, so **B** ships in `debug_meta.images` — and B is the one with no artifact bundle.\n\nResult: every client frame arrives minified, `js_no_source`. Server frames are unaffected.\n\nTwo things make this hard to notice, which is probably why [#20042](\u003chttps://github.com/getsentry/sentry-javascript/issues/20042>) looked theoretical:\n\n* The upload **succeeds and logs success** — under A, the ID that loses.\n* `deleteArtifacts()` does run, so the maps are cleaned up as intended and the build output looks correct.\n\nYou only find out when a client-side error reaches Sentry and the frames are minified. We ran this way for months.\n\n## Additional Context\n\nA fix already exists: [#20042](\u003chttps://github.com/getsentry/sentry-javascript/issues/20042>) (\"fix(react-router): preserve sourcemaps.disable override\") did exactly this and was closed unmerged on 2026-04-20, with:\n\n> Yeah, I'm not sure why the clanker was concerned about that. No one's been complaining about it, and the bug has stayed closed, so I'm (even more) convinced you're right.\n\nFiling this as the missing real-world report: we hit it in production on a React Router 7 app, with minified client frames in Sentry and both debug IDs visible in the deployed bundle.\n\nNote the trailing spread also defeats the two other field-wise merges above it. `release`, `reactComponentAnnotation` and `_metaOptions` are each merged carefully and then overwritten by the raw `unstable_` object whenever the same key is present — so a top-level `release` is silently discarded in favour of an `unstable_.release`. Moving the spread above the explicit keys fixes all four at once.\n\nRelated: getsentry/sentry-javascript#19874 (same symptom, different cause, fixed in 10.47.0), [#15106](\u003chttps://github.com/getsentry/sentry-javascript/issues/15106>) / [#15109](\u003chttps://github.com/getsentry/sentry-javascript/issues/15109>) (the Next.js equivalent).\n\n### Workarounds, for anyone who lands here\n\nEither move everything to the supported top-level fields (`release` supports `name` and `setCommits`, so nothing is lost) and drop `sourcemaps` so `sentryOnBuildEnd` uses its own default of `` `${reactRouterConfig.buildDirectory}/**/*.map` ``:\n\n```ts\nconst sentryConfig: SentryReactRouterBuildOptions = {\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: process.env.SENTRY_ORG,\n project: process.env.SENTRY_PROJECT,\n release: { name: process.env.COMMIT_SHA, setCommits: { auto: true } },\n}\n```\n\n…or, if you need `unstable_sentryVitePluginOptions.sourcemaps`, carry `disable: true` in your own object so the trailing spread re-supplies it.","author":{"url":"https://github.com/lasseklovstad","@type":"Person","name":"lasseklovstad"},"datePublished":"2026-08-01T09:28:43Z","url":"https://github.com/getsentry/sentry-javascript/issues/22929"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:19fede97-606b-cde8-010c-8f5b4a561a51 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A55E:367E0F:55ACD2:73D725:6B043FC0 |
| html-safe-nonce | 2f3971d2ab01cf503fb9179b8cc260a13fbdbbb2b202fc5796ef89c4ede14636 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTVFOjM2N0UwRjo1NUFDRDI6NzNENzI1OjZCMDQzRkMwIiwidmlzaXRvcl9pZCI6Ijc4MDYwNDgzMzE1MDcxODc2NDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4c06a60503fc30e905da87ac62621566326b2ca1c2761fe694a1002f8efd26d9 |
| hovercard-subject-tag | issue:5036377458 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/22929/issue_layout |
| twitter:image | https://opengraph.githubassets.com/17b315aea864f6882cc8f1d2d56c3bf96cea309417dbb135dd8570ff95a47976/getsentry/sentry-javascript/issues/22929 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/17b315aea864f6882cc8f1d2d56c3bf96cea309417dbb135dd8570ff95a47976/getsentry/sentry-javascript/issues/22929 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues I have reviewed the documentation I am using the latest SDK release How do you use Sentry? Sentry Saas (sentry.io) Which SDK ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lasseklovstad |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width