sourcemap inject/upload doesn't recognize a debug ID snippet minified to template literals and shifts Vite 8 chunks one line
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 半日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, node.js, typescript, vite
- 領域
- build-system, cli, devtools
調査の方向性
Start with DEBUGID_REGISTRATION_RE and the bracketed-key regex in packages/cli/src/lib/sourcemap/debug-id.ts, which only accept " or ' as delimiters. Run the reproduction in the issue against a chunk using backtick-quoted registrations; inject --dry-run should report modified 1 today. Done when that case reports skipped 1 with the same delimiter-matching behavior as double quotes, and tests cover both the plain and bracketed forms.
索引モデルが issue の本文から書いたものです。
説明
Environment
sentry0.49.0, via@sentry/vite-plugin/@sentry/bundler-plugins11.12.0- Vite 8.3.8 (Rolldown, Oxc minifier),
build.sourcemap: true - The same check is on
mainat cc90ca1e
Summary
Every frame from a Vite 8 build resolves one generated line off in Sentry.
The bundler plugin injects its debug ID snippet in renderChunk, and Vite 8's minifier then rewrites the snippet's string literals as template literals:
e._sentryDebugIds[t]=`4f39e3c4-c308-4c2e-8975-3241d12fbeef`,e._sentryDebugIdIdentifier=`sentry-dbid-4f39e3c4-c308-4c2e-8975-3241d12fbeef`
The plugin then uploads with sourcemap.upload, which runs inject first. DEBUGID_REGISTRATION_RE only matches a value quoted with " or ':
...\\s*=\\s*(["'])(${DEBUGID_PATTERN})\\1
so the CLI doesn't see the existing registration, prepends a second snippet and adds an empty line to the map's mappings. The uploaded copy and its map agree with each other, but the deployed file doesn't have that extra line, so Sentry resolves every frame one line too high.
This is the same mechanism as #2189, with a different trigger: #2190 taught the check Turbopack's _debugIds form, but it still requires quotes.
Reproduction
dir=$(mktemp -d)
cat > "$dir/chunk.js" <<'EOF'
const a=1;
(()=>{try{let e=globalThis,t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`4f39e3c4-c308-4c2e-8975-3241d12fbeef`,e._sentryDebugIdIdentifier=`sentry-dbid-4f39e3c4-c308-4c2e-8975-3241d12fbeef`)}catch{}})();console.log(a);
//# sourceMappingURL=chunk.js.map
//# debugId=4f39e3c4-c308-4c2e-8975-3241d12fbeef
EOF
echo '{"version":3,"sources":["a.ts"],"names":[],"mappings":"AAAA;AACA","debugId":"4f39e3c4-c308-4c2e-8975-3241d12fbeef"}' > "$dir/chunk.js.map"
npx [email protected] sourcemap inject --dry-run --json "$dir"
Expected: "modified": 0, "skipped": 1, as with the same file using " quotes.
Actual: "modified": 1, "skipped": 0.
Suggested fix
Accept a backtick in the quote class:
- ...\\s*=\\s*(["'])(${DEBUGID_PATTERN})\\1`,
+ ...\\s*=\\s*(["'\`])(${DEBUGID_PATTERN})\\1`,
The backreference still requires matching delimiters. The bracketed key form (\\[\\s*["']${DEBUGID_REGISTRY}["']\\s*\\]) probably wants the same, since a minifier can emit e[`_sentryDebugIds`].
We're working around it with a pnpm patch making exactly this change. With it, all of our uploaded chunks match the deployed files except for the appended //# debugId= comment, and their maps are unchanged.
- 主要言語
- TypeScript
- スター
- 961
- フォーク
- 179
- 平均マージ
- 15時間 33分
- マージ済み PR(30日)
- 476
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
getsentry/toolkit のほかの issue
-
MCP mcp-feedback-pattern
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
getsentry/toolkit#2276 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
CLI enhancement MCP
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
getsentry/toolkit#1908 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
getsentry/toolkit#1471 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
get_sentry_resource gives no guidance for Explore > Errors list URLs対応中かも @sentry-junior が今日担当しました。 オープンMCP mcp-feedback-pattern
難易度 2/5 1〜3時間 初心者へのやさしさ 32/100
getsentry/toolkit#2278 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
getsentry/toolkit#2275 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
getsentry/toolkit の issue をすべて見る
似ている issue
-
Add: BOM Cineオープンapproved check:passed streams:add
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug platform-android
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Termix-SSH/Mobile#146 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
devswha/herdr-web-ui#3875 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100