Files
supabase/apps/studio/scripts
Alaister YoungandAlaister Young 8d08198cb4 fix(studio): preserve TanStack server source maps (#51051)
TanStack server maps now preserve original TypeScript locations through
both Nitro build stages. Sentry can upload those maps before final
server and public maps are removed; intermediate SSR maps remain
available for composition.

**Changed:**

- Enable Nitro server maps with original source content and compose
adjacent SSR maps through a build-only Vite loader scoped to the Nitro
environment.
- Keep intermediate maps until Nitro consumes them. Apply Sentry’s
bundler plugin to client and final server outputs, preventing
intermediate SSR IDs from overriding the final uploaded map ID. Remove
final server maps after eligible uploads; skipped or unauthenticated
uploads retain private maps.
- Preserve the existing Sentry release, project, credentials,
middleware, and separate Next configuration.

**Added:**

- Real two-stage Node and Vercel build regressions for original
TypeScript positions, runtime debug-ID matching against the installed
Sentry SDK, map cleanup timing, malformed maps, and loader boundaries.

## To test

- Build an actual TanStack preview with the existing Sentry upload
settings. Confirm client and final server uploads include maps,
intermediate SSR maps remain available for composition, final/public
maps are removed, and the deployed function remains within its size
limit.
- Inspect a public JavaScript asset's map URL; it should not expose a
source map.
- Build with uploads skipped or credentials absent; private server maps
should remain, with no public maps.
- Reload an existing project and navigate through general settings and
an existing Edge Function without editing or submitting anything.
- Before production rollout, confirm browser and server events resolve
to useful original source locations in the intended Sentry project.

Validation: 22 focused tests, Studio typecheck, scoped ESLint,
formatting, knip, full source lint ratchet, and both framework
production builds passed. Full-app artifact tracing resolves a compiled
handler to its original TypeScript line with exact source content. The
skipped-upload Vercel build contains zero public maps and no function
symlinks. Local TanStack browser checks passed for project/reload,
untouched general settings and support, and an existing function
editor/reload; a final retest after the runtime-ID fix passed with no
module or Sentry errors. A previously observed devtools
support-lifecycle warning remains unattributed. An explicit TanStack
preview of this commit reached READY: client and final Nitro uploads
succeeded, with no intermediate SSR upload. A shell-referenced
JavaScript asset returned 200 with immutable caching and its map URL
returned 404. Upload reports still contain unmapped files; original app
TypeScript mapping and runtime-ID association are established by build
artifacts/fixtures, while real event deobfuscation remains rollout QA.
Deployment acceptance confirms this preview fits its configured function
limits; exact deployed size and post-upload server contents were not
independently downloaded. No package patch, dependency, or new
environment variable is required.

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-10-07 19:30:08 +02:00
..