sourcemap inject/upload doesn't recognize a debug ID snippet minified to template literals and shifts Vite 8 chunks one line
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 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 分鐘
- 30 天內合併 PR
- 476
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 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
-
難度 2/5 1-3 小時 新手友好度 72/100
AykutSarac/jsoncrack.com#616 ·
-
nip27: long hashtag swallows the rest of the content, lone # gives an empty hashtag可能已有人在做 @bardrop 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
nbd-wtf/nostr-tools#578 ·
-
難度 2/5 1-3 小時 新手友好度 68/100
backnotprop/plannotator#3427 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
microsoft/Power-CAT-Copilot-Studio-Kit#942 ·
維護者通常 1 天內回覆
-
[BUG]: Duplicate preposition in heading and unformatted feedback text on Strengthen Argument page未關閉bug
難度 2/5 1-3 小時 新手友好度 72/100
AOSSIE-Org/DebateAI#801 · 1 則留言 ·
維護者通常 1 天內回覆