Skip to content

fix(tanstackstart-react): Delete only the source maps that Sentry enabled - #25362

Merged
s1gr1d merged 4 commits into
developfrom
sig/tanstack-start-delete-source-maps
Oct 16, 2026
Merged

s1gr1d merged 4 commits into
developfrom
sig/tanstack-start-delete-source-maps

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

The default filesToDeleteAfterUpload: ['./**/*.map'] does not enter dot directories like .output, so the client source maps that Sentry enabled stayed in the build output of Nitro apps.

  • Deletes the source maps in the output directory of each environment where only Sentry turned them on.
  • Keeps source maps that the user enabled with build.sourcemap, an environment setting or build.rolldownOptions.output.sourcemap.
  • Deletes only in the output directories of the build. The old default ./**/*.map also deleted source maps of dependencies in node_modules (npm and yarn layouts).
  • Warns on Vite 7, where Sentry only knows build.outDir.

Refs #21012

TanStack Start splits route files into virtual modules such as `index.tsx?tss-serverfn-split`.
The uploaded source maps kept these queries and paths relative to the map's directory, so frames
did not show the path of the source file.

Remove the split queries and make source paths relative to the project root, so frames show paths
such as `src/routes/index.tsx`. A user's `sourcemaps.rewriteSources` still takes precedence.
…bled

The default `filesToDeleteAfterUpload: ['./**/*.map']` does not enter dot directories like
`.output`, so source maps that Sentry enabled stayed in the client build of Nitro apps.

Delete the source maps in the output directory of each environment that only has source maps
because Sentry enabled them. Keep source maps that the user enabled with `build.sourcemap`, an
environment setting or `build.rolldownOptions.output.sourcemap`. Warn on Vite 7, where Sentry
only knows `build.outDir`.
@s1gr1d
s1gr1d marked this pull request as ready for review October 14, 2026 12:04
@s1gr1d
s1gr1d requested a review from a team as a code owner October 14, 2026 12:04
@s1gr1d
s1gr1d requested review from chargome and mydea and removed request for a team October 14, 2026 12:04
@s1gr1d

s1gr1d commented Oct 14, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2f5889c. Configure here.

@JPeer264 JPeer264 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: Wouldn't it be easier to add another default?

filesToDeleteAfterUpload: ['./**/*.map', './.*/**/*.map']

Base automatically changed from sig/tanstack-start-rewrite-sources to develop October 14, 2026 14:04
@s1gr1d

s1gr1d commented Oct 14, 2026 •

Copy link
Copy Markdown
Member Author

Good question! Howeeever, a static glob is one decision for the whole project, while it differs per environment whether Sentry enabled the source maps.

For example, the glob would be used whenever the top-level build.sourcemap is unset, but source maps can also be enabled in e.g. nitro({ sourcemap: true }) (writes server maps to .output/server), and ./.*/**/*.map would delete them, although the user wanted them. Or also @cloudflare/vite-plugin (enables worker maps itself).

Also, the glob has no ignore list, so ./.*/**/*.map would match every dot folder in the root (.wrangler, caches, …).

Reading the output directories from the resolved config also covers Nitro presets like .vercel/output or .netlify without extra globs.

Created a PR for Nuxt to improve this: #25450

…-delete-source-maps

# Conflicts:
#	packages/tanstackstart-react/src/vite/sourceMaps.ts
@s1gr1d
s1gr1d requested a review from JPeer264 October 14, 2026 15:02
@JPeer264

Copy link
Copy Markdown
Member

that's a great point. Let's go with the new flow then 👍

@s1gr1d
s1gr1d added this pull request to stack #25439 October 16, 2026 08:29

@JPeer264 JPeer264 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a general question and maybe a little broad. Is there any possibility that the output dir is either not set, or a different option can be set (or set via ENV variables)? Just asking since if this one is not set, we're not deleting any sourcemaps by default, as the default glob is gone now.

Maybe we should add a console.warn (without debug) for cases where the filesToDelete is empty?

Comment thread packages/tanstackstart-react/src/vite/sourceMaps.ts
In debug mode, log that no source maps are deleted after the upload when Sentry did not enable
source map generation for the build. Before, debug mode logged nothing in this case.
@s1gr1d

s1gr1d commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Is there any possibility that the output dir is not set, or set by a different option or ENV variables? … Maybe add a console.warn when filesToDelete is empty?

The output dir is always set: Vite defaults build.outDir to dist, and output.dir (e.g. Nitro's) takes precedence.
An empty filesToDelete... means Sentry enabled no source maps, so I think a warning would only be noise for users with their own settings. But I added a debug log for that case.

@s1gr1d
s1gr1d merged commit 20ba3ef into develop Oct 16, 2026
372 of 374 checks passed
@s1gr1d
s1gr1d deleted the sig/tanstack-start-delete-source-maps branch October 16, 2026 12:13
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.

2 participants