Skip to content

sentryTanstackStart source maps plugin returns full config from Vite config hook, corrupting Nitro server assets #23753

Description

@glekner

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/tanstackstart-react

SDK Version

10.72.0 (also reproduced on 10.69.0)

Framework Version

vite 8.2, nitro 3.0.260610-beta (Vite plugin mode), Node 24

Steps to Reproduce

makeEnableSourceMapsVitePlugin (the sentry-tanstackstart-react-source-maps plugin) returns the entire user config from its Vite config hook:

config(viteConfig) {
  return {
    ...viteConfig,
    build: {
      ...viteConfig.build,
      sourcemap: getUpdatedSourceMapSettings(viteConfig, options),
    },
  };
}

Per the Vite plugin docs, the config hook should return a partial object that gets merged into the existing config. Returning the full config merges the config into itself. When Nitro's Vite plugin is present, this duplicates its internal asset processing, and every serverAssets file gets embedded as wrapped module source instead of file content.

Minimal repro (no TanStack app needed, the plugin is enough):

package.json deps: [email protected], vite@^8.2.0, @sentry/[email protected]

vite.config.ts:

import { defineConfig } from 'vite';
import { nitro } from 'nitro/vite';
import { sentryTanstackStart } from '@sentry/tanstackstart-react/vite';

export default defineConfig({
  plugins: [
    nitro({
      serverAssets: [{ baseName: 'test', dir: './assets' }],
      handlers: [{ route: '/asset-check', handler: './routes/asset-check.ts' }],
    }),
    sentryTanstackStart({ autoInstrumentMiddleware: false, telemetry: false }),
  ],
});

assets/hello.txt: hello asset content\n

routes/asset-check.ts:

import { defineHandler } from 'nitro';
import { useStorage } from 'nitro/storage';

export default defineHandler(async () => {
  const item = await useStorage('assets:test').getItem('hello.txt');
  return { type: typeof item, length: (item as string).length, preview: JSON.stringify(item) };
});

Then vite build and run the output server.

Isolation steps I ran:

  1. No Sentry plugin at all: asset is correct.
  2. Plain sentryVitePlugin from @sentry/vite-plugin: correct (it only adds the debug id banner).
  3. Only the sentry-tanstackstart-react-source-maps sub plugin: broken.
  4. A bare test plugin with the same config(c) { return { ...c, build: { ...c.build, sourcemap: 'hidden' } } }: broken, with zero Sentry code involved. So the full config spread is the trigger.
  5. Same test plugin returning only { build: { sourcemap: 'hidden' } }: correct.

Expected Result

GET /asset-check returns the file content:

{"type":"string","length":20,"preview":"\"hello asset content\\n\""}

Actual Result

useStorage('assets:test').getItem('hello.txt') returns the wrapped module source:

{"type":"string","length":38,"preview":"\"export default \\\"hello asset content\\\\n\\\"\""}

The built server bundle contains var hello_default = "export default \"hello asset content\\n\"" instead of the content.

This is silent data corruption. We found it in production because an executable bundle we ship as a Nitro server asset turned into an inert module, and our LLM prompt files shipped with an export default " prefix and escaped newlines.

Suggested fix, return a partial config as the Vite docs describe:

config(viteConfig) {
  return {
    build: { sourcemap: getUpdatedSourceMapSettings(viteConfig, options) },
  };
}

I verified this exact change fixes the repro. Happy to send a PR if useful.

Activity

  1. linear-code commented on Aug 29, 2026

    @linear-code
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Aug 29, 2026
  3. self-assigned this
    on Aug 31, 2026
  4. s1gr1d commented on Aug 31, 2026

    @s1gr1d
    Member

    Thank you for this very detailed issue description! Feel free to open a PR with the fix, this looks good 👍
    Something similar has also been done for SolidStart already: https://github.com/getsentry/sentry-javascript/pull/23090/changes#diff-9138561f0c1b4b338131db20289abac54801da115f5b0fdc934a7d02d2488c87R160-R166

  5. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Aug 31, 2026
  6. nicohrubec commented on Oct 1, 2026

    @nicohrubec
    Member

    This will be fixed in the next v11 release and I'll also backport to v10. Thanks again for raising!

  7. added a commit that references this issue on Oct 1, 2026
    ce2631a
  8. github-actions commented on Oct 2, 2026

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #24929, which was included in the 11.3.0 release.

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