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

未关闭
#25,679 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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).

主要语言
TypeScript
星标
8.8k
派生
1.9k
平均合并
1 天 8 小时
30 天内合并 PR
744

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/sentry-javascript 的其他 Issue

查看 getsentry/sentry-javascript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。