Skip to content

fix(tanstackstart-react): Unminify server errors in Nitro builds - #25360

Open
s1gr1d wants to merge 9 commits into
developfrom
sig/tanstack-start-source-maps
Open

s1gr1d wants to merge 9 commits into
developfrom
sig/tanstack-start-source-maps

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Server errors in TanStack Start stayed minified: Nitro's source maps were off, or stopped at its intermediate SSR bundle in node_modules/.nitro.

  • Loads the SSR source maps into Nitro's build, so the final maps point to src/.
  • Turns on 'hidden' Nitro source maps only if no config sets them, and always keeps sourcesContent (sourcemapMinify: false).
  • Deletes the Nitro source maps that Sentry turned on after the upload.

Nuxt 5 has the same Nitro issues: #25325 fixes sourcesContent, and the map composition can be reused there.

Based on #24356 by @kyrylolvov. Stacked on #25362.

Fixes #21012

s1gr1d and others added 3 commits October 14, 2026 13:53
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`.
Server errors in TanStack Start stayed minified. Sentry did not turn on Nitro's source
maps, and Nitro's maps stopped at its intermediate SSR bundle in `node_modules/.nitro`.

Load the SSR source maps into Nitro's build, so the final maps point to `src/`. Turn on
'hidden' Nitro source maps only if no Vite or Nitro config sets them, and always set
`sourcemapMinify: false` to keep `sourcesContent`. Delete the Nitro source maps that Sentry
turned on after the upload.

Fixes #21012
Co-Authored-By: kyrylolvov <kyrylolvov@icloud.com>
@s1gr1d
s1gr1d force-pushed the sig/tanstack-start-source-maps branch from a0e6667 to a58eeb9 Compare October 14, 2026 11:55
@s1gr1d
s1gr1d changed the base branch from develop to sig/tanstack-start-delete-source-maps October 14, 2026 11:56
@s1gr1d
s1gr1d marked this pull request as ready for review October 14, 2026 11:58
@s1gr1d
s1gr1d requested a review from a team as a code owner October 14, 2026 11:58
@s1gr1d
s1gr1d requested review from chargome and mydea and removed request for a team October 14, 2026 11:58
@s1gr1d
s1gr1d requested a review from nicohrubec October 14, 2026 12:01
Credit @kyrylolvov for #24356, which this fix is based on.
@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 38a674a. Configure here.

…layers

Sentry reads Nitro's config sources from the internal `_c12` option. Link the issue that asks
Nitro to expose them, so the code can move to the public option later.
…-delete-source-maps

# Conflicts:
#	packages/tanstackstart-react/src/vite/sourceMaps.ts
@s1gr1d
s1gr1d added this pull request to stack #25439 October 16, 2026 08:29
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.
Base automatically changed from sig/tanstack-start-delete-source-maps to develop October 16, 2026 12:13
kodiakhq Bot pushed a commit to mheob/kurze-url that referenced this pull request Oct 18, 2026
## Summary

`apps/web` now builds with Nitro v3's `nitro/vite` plugin instead of `@tanstack/nitro-v2-vite-plugin`. TanStack removed the old plugin upstream in TanStack/router#8537, and its last release was 1.155.2. TanStack's hosting guide and examples use `nitro/vite`, and so do Sentry's e2e apps.

**This PR is a draft until the Vercel preview checks below pass.**

## Changes

- **`apps/web/vite.config.ts`**
  - `nitroV2Plugin(...)` is replaced by `nitro({ compatibilityDate: '2026-09-04', sourcemap: false })`.
  - The plugin order is unchanged, and the Sentry plugins stay last.
  - No preset is set, because Nitro detects Vercel by itself.
  - Comments are rewritten for Nitro v3.
- **Catalog**
  - `nitro` is pinned exactly to `3.0.260903-beta`. That is the current `latest`, and it is a beta: Nitro v3 is not GA yet.
  - The nitropack 2.13.4 tree leaves the lockfile: 162 packages that only it reached, plus one peer resolution that now uses the version already in the tree.
- **Server source maps stay off on purpose (`sourcemap: false`).** Nitro 3 already defaults to `false`. But getsentry/sentry-javascript#25360, an open PR, would switch Nitro's server maps to `hidden` by itself whenever the Nitro config sets nothing. A routine, auto-merged Sentry minor would then start emitting and uploading server maps without anyone deciding to. The pin keeps the 2026-10-03 decision explicit, and #25360 is the moment to revisit it.
- **Sentry `filesToDeleteAfterUpload`.** The client maps now land in `.output/public` locally and in `.vercel/output/static` on Vercel. The existing globs cover both. `./dist/**/*.map` stays, with a comment: it only matters if Nitro never ran and Vercel served `dist/`.
- **`.github/renovate.json`.** A new rule makes `nitro` updates wait for approval on the Dependency Dashboard and takes them out of the non-major group. A new date-stamped beta counts as a patch and would otherwise auto-merge on green. The required e2e check would not catch leaked maps, changes in Sentry's uploads, or a drift in runtime or region.
- **Docs.** CLAUDE.md's Sentry source-map entry and Renovate entry are updated. `docs/research/2026-10-03-server-source-maps.md` is marked superseded: its four nitropack-2 internals no longer apply.

## Behaviour changes (verified locally)

- **Function name on Vercel:** `__fallback.func` becomes `__server.func`.
- **Runtime:** `nodejs22.x` becomes `nodejs24.x`. Nitro maps the build machine's Node major, and the project is set to `24.x`.
- **Function size:** 23 MB becomes 8.8 MB.
- **Server source maps:** before, the function shipped 43 server `.map` files that were never deleted. Now it ships none.
- **Caching:** `/assets/*` gets `cache-control: public, max-age=31536000, immutable`.
- **Sentry plugin:** it runs in three Vite environments (client, ssr, nitro).
  - Release create and finalize are idempotent, and the deploy record is created only once per process.
  - `ssr` and `nitro` log "No source maps found…" and upload nothing.

## Motivation

This is a follow-up from #133. The v2 plugin still works but is unmaintained, and nothing after it is a v2 path. TanStack and Sentry have both moved to Nitro v3.

## Testing

**Local**
- `pnpm check`, `pnpm typecheck`, `pnpm check:vite-plus` and `pnpm install --frozen-lockfile` pass.
- 883 unit tests and 130 Storybook tests pass, and `build-storybook` succeeds.
- `routeTree.gen.ts` is unchanged and still has its `Register` block.
- The build succeeds with 0 maps in `.output`. `node .output/server/index.mjs` serves `/login` with 200, so `start` and Playwright's `webServer` still work.
- `VERCEL=1` builds produce `__server.func` with `nodejs24.x` and 0 maps.
- `vp dev` serves `/login` with 200.

**Gate before marking ready, on this PR's preview**
1. The build log shows `Using nodejs24.x runtime`, exactly one "Successfully uploaded source maps to Sentry", and no Sentry errors.
2. Sentry has one release for the commit and exactly one `preview` deploy record.
3. `__server.func/.vc-config.json` has `"runtime": "nodejs24.x"`, and there is no `.map` under `static/` or in the function. `GET /assets/<chunk>.js.map` serves no map.
4. The deployment reports `regions: ["fra1"]`.
5. `/assets/*` carries the immutable cache header, and HTML routes do not.
6. "e2e against the preview" is green.

## Breaking Changes

None for users of the app. For contributors: the server build output and the Vercel function layout changed as described above.

**Known and not blocking:**
- The build log carries about 478 harmless `MODULE_LEVEL_DIRECTIVE "use client"` warnings.
- nitrojs/nitro#4693: in dev only, a request after a main-thread stall of more than about 5 seconds, such as a debugger pause, can fail with ECONNRESET.

This branch has not been deployed

No deployments
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.

tanstack-start: source maps support for server code

1 participant