Debug ID changes the bytes of polyfills and main but not their file names, so cached files fail the SRI check
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 55/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- angular, typescript
- 領域
- build-system
研究方向
Start by tracing how the Angular build builder adds debug IDs to esbuild-named main and polyfills files, and compare that with the chunk optimizer fix in #34583. Use the reproduction steps to build with source maps and subresource integrity enabled, then check whether changed JavaScript bytes receive changed filenames and the generated index.html digests match. Done means the reported cache and SRI mismatch is reproduced and fixed for these files.
由索引模型根據 Issue 內容生成。
描述
Command
build
Is this a regression?
Yes. It started with the debug IDs in 22.1.0.
Description
Follow-up to #34574.
The builder names polyfills-<hash>.js and main-<hash>.js first. Then it adds a //# debugId=<id> line to the file. It computes <id> from the source map after it rewrites the map to add x_google_ignoreList. The file name does not cover that line.
So when a builder release writes the source map differently, the JS bytes change and the file name stays the same. 22.1.8 did that. Commit 5a0d226b7c moved x_google_ignoreList to the start of the map.
With subresourceIntegrity, the new index.html pins the new bytes. A CDN or browser cache that kept the old file under the same URL serves the old bytes, and the browser blocks the script. This happened to us in production with polyfills-<hash>.js.
#34583 fixed this for the chunks of the chunk optimizer. It does not cover files that esbuild names, such as main and polyfills. 22.2.6 still computes their debug ID from the rewritten map.
Minimal Reproduction
npx @angular/[email protected] new repro --defaults --ssr=false
cd repro
npm install zone.js
npm install -D @angular/[email protected]
npx ng config projects.repro.architect.build.options.polyfills '["zone.js"]'
npx ng config projects.repro.architect.build.configurations.production.sourceMap true
npx ng config projects.repro.architect.build.configurations.production.subresourceIntegrity true
npx ng build && mv dist/repro/browser ../build-22.1.6
npm install -D @angular/[email protected]
npx ng build && mv dist/repro/browser ../build-22.1.8
Both builds write polyfills-QWJLBG44.js and main-HHND32NM.js. In each file, only the //# debugId= line differs:
polyfills-QWJLBG44.js
build-22.1.6: //# debugId=d932f97d-b667-5462-b3b7-b328a1ce7f5a
build-22.1.8: //# debugId=81c8766a-7d41-50fd-ac6d-16c3c4ed6358
main-HHND32NM.js
build-22.1.6: //# debugId=e3a30145-1442-57c2-96a7-a88f9bf43b0a
build-22.1.8: //# debugId=50dd2d3c-f1e3-5224-9587-43f24f562421
The two index.html files pin different hashes for the same URLs. For both files, the two source maps have the same content in a different key order.
Exception or Error
Failed to find a valid digest in the 'integrity' attribute for resource 'https://example.com/polyfills-JTOAPWZJ.js' with computed SHA-384 integrity '...'. The resource has been blocked.
Your Environment
Angular CLI: 22.1.8
@angular/build: 22.1.6, then 22.1.8
@angular/core: 22.2.5
zone.js: 0.16.3
Node: 24.17.0
OS: macOS
Anything else relevant?
Expected: when the bytes of a hashed file change, its name changes too.
A possible fix is to compute the debug ID from the JS before the builder adds the debug ID line, not from the rewritten map. The file name already covers the JS.
- 主要語言
- TypeScript
- 星號
- 27k
- 分支
- 11.8k
- 平均合併
- 1 天 3 小時
- 30 天內合併 PR
- 271
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
angular/angular-cli 的其他 Issue
-
Font inlining cache is not created or reused可能已有人在做 @nagahara-naoki 今天認領。 未關閉area: @angular/build
難度 2/5 1-3 小時 新手友好度 82/100
angular/angular-cli#34719 ·
維護者通常 1 天內回覆
-
area: @angular/cli
難度 3/5 半天 新手友好度 42/100
angular/angular-cli#34716 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 72/100
angular/angular-cli#34688 ·
維護者通常 1 天內回覆
-
`ng generate application` produces a missing stylesheet when a workspace component type is configured可能已有人在做 @nagahara-naoki 於 2 天前認領。 未關閉area: @schematics/angular
難度 2/5 1-3 小時 新手友好度 25/100
angular/angular-cli#34684 ·
維護者通常 1 天內回覆
-
Tailwind CSS v4 classes in new or moved files are not picked up by ng serve until another rebuild可能重新可做 關聯的 PR 已關閉且未合併。 未關閉area: @angular/build
難度 4/5 3-5 天 新手友好度 35/100
angular/angular-cli#34446 ·
維護者通常 1 天內回覆
查看 angular/angular-cli 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
OHDSI/Data2Evidence#3693 ·
維護者通常 3 天內回覆
-
severity:low triage:confirmed
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
bug package:workers-shared
難度 2/5 1-3 小時 新手友好度 72/100
cloudflare/workers-sdk#16924 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug frontend priority: low
難度 2/5 1-3 小時 新手友好度 82/100
nooriegarg/ContribIQ#74 ·
維護者通常 1 天內回覆
-
parse: child keys like `007`, `1e3`, `0x1f`, `-1` make the parent an empty array and hide the value未關閉
難度 2/5 1-3 小時 新手友好度 78/100