Compose server source maps and debug IDs across multi-pass builds

Offen
#25,679 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv

Rechercherichtung

Start with packages/core/src/utils/debug-ids.ts and the SvelteKit workaround in packages/sveltekit/src/vite/sourceMaps.ts, then review the linked source-map and framework issues. Map how the bundler plugins expose hooks and CLI commands before scoping the shared finalization step; done means final JavaScript outputs have composed source maps and one debug ID, with runtime collisions diagnosed.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Feature

Several frameworks run a second bundling or merging step over the output of the step where Sentry injects debug IDs and generates source maps:

  • Nitro bundles the Vite SSR output again.
  • wrangler and OpenNext bundle the worker.
  • SvelteKit adapters merge files.
  • TanStack Start and Bun builds have similar steps.

When the source-map chain is not composed through that later step, or several injected debug IDs end up in one output file, server stack traces resolve to intermediate build files or not at all. Issues: #21012, #20084, #20051, #19213, #19396, #25618.

There are framework-specific fixes: SvelteKit flattens with sorcery (packages/sveltekit/src/vite/sourceMaps.ts), #25333 handles Nuxt 5, and #25670 handles Bun. Each framework solves the same problem separately, and the bundler-plugins core has nothing for it.

There are also two failure modes on the runtime side:

  • When several _sentryDebugIds snippets end up in one file, they all map to the same filename and the last one wins.
  • Native _debugIds override Sentry's for the same file (packages/core/src/utils/debug-ids.ts).

Both fail silently.

Proposal
  1. A shared, opt-in "finalize output" step in @sentry/bundler-plugins, exposed as a plugin hook and as a CLI command that can run on a final output directory. For each final .js file it should:

    • follow the sourceMappingURL chain through the intermediate maps and compose it back to the original sources;
    • reduce the file to one debug ID (remove duplicate snippets and stamp a single ID);
    • then upload.

    Framework SDKs (SvelteKit, Nuxt/Nitro, TanStack Start, Cloudflare/wrangler, Bun) would enable it inside their existing plugins and replace their own workarounds. This would build on the zero-config source-map work in #25609.

  2. Runtime detection. Log a debug warning in getFilenameToDebugIdMap when more than one debug ID resolves to the same filename, so collisions can be diagnosed.

Not fixable on our side, and worth stating in docs: build steps that emit no source map at all (for example OpenNext, opennextjs-cloudflare#1352), and Turbopack maps that leave mangled names out of names (#18248, vercel/next.js#87896).

Vorherrschende Sprache
TypeScript
Sterne
8.8k
Forks
1.9k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
744

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus getsentry/sentry-javascript

Alle Issues in getsentry/sentry-javascript

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.