feat(tanstackstart-react): Compose Nitro server source maps to original TypeScript - #24356
kyrylolvov wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 77b0edd. Configure here.
| } | ||
|
|
||
| return id.includes('/.nitro/vite/services/ssr/') || id.includes('.nitro\\vite\\services\\ssr\\'); | ||
| } |
There was a problem hiding this comment.
Feat lacks integration or E2E test
Medium Severity
This feat only adds unit tests for Nitro source-map composition. An integration or E2E test is needed to confirm server-function errors unminify to the original TypeScript in a real TanStack Start plus Nitro build. I flagged this because the review guidelines require at least one integration or E2E test on feat PRs.
Additional Locations (1)
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 77b0edd. Configure here.
| plugins.push(makeNitroSourceMapsPlugin(options)); | ||
| } | ||
|
|
||
| plugins.push(...makeAddSentryVitePlugin(options)); |
There was a problem hiding this comment.
Bug: The source map deletion plugin runs before the source map enabling plugin. This causes intermediate SSR source maps to be deleted prematurely, breaking server-side source map composition in the default configuration.
Severity: HIGH
Suggested Fix
Reorder the plugin registration in sentryTanstackStart.ts. The makeEnableSourceMapsVitePlugin call should be placed before the makeAddSentryVitePlugin call. This ensures the config.build.sourcemap property is set before the deletion plugin's logic runs, preventing it from incorrectly scheduling the deletion of all map files.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: packages/tanstackstart-react/src/vite/sentryTanstackStart.ts#L110
Potential issue: In the default configuration, the Vite plugin responsible for deleting
source maps after upload (`sentry-tanstackstart-files-to-delete-after-upload-plugin`) is
scheduled before the plugin that enables them
(`sentry-tanstackstart-react-source-maps`). Because the deletion plugin checks if
`build.sourcemap` is defined before the enabling plugin has a chance to set it, it
defaults to scheduling the deletion of all map files (`./**/*.map`). This broad pattern
incorrectly deletes intermediate SSR source maps required by Nitro's second build pass.
As a result, server-side stack traces are not correctly unminified in Sentry. This issue
does not occur if a user manually configures `build.sourcemap` or
`filesToDeleteAfterUpload`.
Did we get this right? 👍 / 👎 to inform future reviews.
ec73d27 to
77b0edd
Compare


Server-function errors in TanStack Start stayed minified even when source maps were uploaded. Frontend maps already unminified. The server bundle is a second Nitro pass, and its maps never pointed at the original TypeScript.
Fixes #21012
Root cause
TanStack Start compiles server code twice: Vite SSR intermediates under
node_modules/.nitro/, then Nitro's final Rollup into.output/server. Sentry uploaded the final maps.Nitro's
sourcemapMinifyclearsmappingsfor any chunk whose path containsnode_modules. The intermediates live there, so those maps were often empty. Separately, Rollup loaded the intermediates as plain JS and ignored the adjacent.map, so even intact maps pointed at generated files. Settingvite.build.sourcemapdoes not setnitro.sourcemap. Uploading both folders with sentry-cli does not compose them.Solution
sentryTanstackStart()now configures Nitro the same way SolidStart's Vite plugin does (enforce: 'pre', hidden maps if unset,sourcemapMinify: false) and adds a Rolluploadhook that returns{ code, map }for the SSR intermediates so the final maps compose through to TypeScript. Source paths like../../../src/...?tss-serverfn-splitare rewritten to./src/...on upload.@sentry/nitrois not a dependency: that module also enables tracing-channel instrumentation and a second upload, which would double-instrument TanStack Start.Before

After
