`release.inject` gives startup chunks new file names on every commit

未關閉
#26,485 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
javascript, typescript, vite, webpack

研究方向

Start by tracing how release.inject is applied to startup chunks in the bundler plugins, then compare the Vite transformIndexHtml and webpack HTML plugin entry points mentioned in the issue. Check how release values reach the SDK at runtime and how existing tests cover injected releases and output hashes. Done means the selected behavior avoids changing unchanged chunk hashes on each commit, with tests and documentation covering the caching effect.

由索引模型根據 Issue 內容生成。

描述

Bug
Problem Statement

release.inject defaults to true, and release.name defaults to the current commit. So every chunk that gets the release snippet gets a new content hash on every commit, even when its code did not change.

Since #25541 this only hits startup chunks, but those are exactly the files every returning visitor needs first. Other chunks import them by their hashed file names, so the renames spread from there.

On @sentry/nuxt 10.47, a deploy that changed one image renamed 140 of 147 client files. release: { inject: false } fixed it.

This is a very weird default. A bundler plugin should not break the bundler's content hashing unless you ask it to, and most users will never notice that every deploy throws away their users' cache.

Solution Brainstorm
  • Keep the release out of content-hashed files: inject it into the HTML (transformIndexHtml in Vite, the HTML plugin in webpack) or into one small unhashed file.
  • Or default release.inject to false when the SDK already gets the release some other way (Sentry.init({ release }), framework runtime config).
  • Either way, document the caching cost on release.inject.

Debug IDs are not the problem: they come from the file content, so they don't change the hashes.

Additional Context

Same problem in the old repo: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/680 (closed, but people still hit it there).

Workaround: release: { inject: false }, and pass release to Sentry.init at runtime.

主要語言
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 摘要。