Title: Debug ID changes the bytes of an optimized chunk but not its file name, so cached files fail the SRI check · Issue #34574 · angular/angular-cli · GitHub
Open Graph Title: Debug ID changes the bytes of an optimized chunk but not its file name, so cached files fail the SRI check · Issue #34574 · angular/angular-cli
X Title: Debug ID changes the bytes of an optimized chunk but not its file name, so cached files fail the SRI check · Issue #34574 · angular/angular-cli
Description: Command build Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was 22.0.x Description Since 22.1.0 (#33110), the application builder adds a //# debugId=<...
Open Graph Description: Command build Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was 22.0.x Description Since 22.1.0 (#33110), the ...
X Description: Command build Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was 22.0.x Description Since 22.1.0 (#33110), the ...
Opengraph URL: https://github.com/angular/angular-cli/issues/34574
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Debug ID changes the bytes of an optimized chunk but not its file name, so cached files fail the SRI check","articleBody":"### Command\n\nbuild\n\n### Is this a regression?\n\n- [x] Yes, this behavior used to work in the previous version\n\n### The previous version in which this bug was not present was\n\n22.0.x\n\n### Description\n\nSince 22.1.0 (#33110), the application builder adds a `//# debugId=\u003cuuid>` line to each browser JS file when script source maps are enabled. The ID comes from the bytes of the source map.\n\nWhen the chunk optimizer runs (by default when the build has 3 or more lazy chunks), Rolldown gives the chunks their final file names. The `[hash]` in these names covers the code of the chunk only. It does not cover the source map. The debugId line is added after that.\n\nA change that keeps the JS code of a chunk the same but changes its source map (for example, a change to a TypeScript type or to a comment) gives this result for a chunk that does not import other chunks:\n\n1. The file name stays the same.\n2. The debugId changes, because the source map changed.\n3. The file bytes change, because the debugId line changed.\n4. The SRI hash in `index.html` changes to match the new bytes.\n\nIn one build, the HTML and the files match. Across two builds, the rule \"same hashed file name means same content\" is no longer true.\n\nHosting setups depend on this rule: they cache hashed files as immutable. Any cache can keep the file from the previous build: a CDN such as Cloudflare, the browser cache, or a proxy. That cache then serves the old bytes together with the new `index.html`. The integrity check fails, the browser blocks the file, and the modules in it do not load.\n\nBefore 22.1.0 there was no debugId line, so the bytes of a hashed file changed only when its name changed.\n\n**Expected behavior:** if the bytes of a hashed output file change, its file name changes too.\n\n### Minimal Reproduction\n\nRepository: https://github.com/virgiliojr/angular-debugid-sri-repro\n\nThe app is a plain `ng new` app (Angular CLI 22.2.2) with 3 lazy routes, so the chunk optimizer runs. `lazy-a` and `lazy-b` use `src/app/shared/label.ts`. This module has no imports, so it becomes its own chunk.\n\n1. Run `npm ci`.\n2. Run `npx ng build --source-map --subresource-integrity`.\n3. In `dist/repro/browser/`, find the chunk that contains `label:`. Write down its file name and its SHA-384.\n4. In `src/app/shared/label.ts`, add `extra?: number;` to the `LabelInput` interface. This is a type-only change: the JS output of `label.ts` stays the same.\n5. Run `npx ng build --source-map --subresource-integrity` again.\n6. Find the chunk that contains `label:` again.\n\n`bash compare-builds.sh` in the repository does steps 2 to 6 and prints the result below.\n\n**Actual result:**\n\n```text\nBuild 1\n file name: chunk-z-ytF2G0.js\n sha384 of bytes: sha384-Y7f5K4V0FTCrXc6JQ2tGE+VllRWg501EixeFEPMjNMboDgwfeRc9E6l8oHlqTbX5\n debugId line: //# debugId=105cedd6-2603-584f-8e8d-7801d6020b96\n sha in index.html: yes\nBuild 2\n file name: chunk-z-ytF2G0.js\n sha384 of bytes: sha384-bgCbCJmJexbhKCHeS4kpofe2lKBPWJ1f3JpK9668+/jD2mfiEYADUy5xD1Usr1dZ\n debugId line: //# debugId=9c547775-c029-5af8-ba7e-25c70949f1b6\n sha in index.html: yes\n\nDiff of the chunk between the two builds:\n2c2\n\u003c //# debugId=105cedd6-2603-584f-8e8d-7801d6020b96\n---\n> //# debugId=9c547775-c029-5af8-ba7e-25c70949f1b6\n```\n\nThe file name is the same, but the bytes and the SRI hash in `index.html` are different.\n\n**Expected result:** if the bytes are different, the file name is different too.\n\nTo see the failure in a browser, serve the output of build 2, but serve `chunk-z-ytF2G0.js` from build 1. This is what a cache does after a deployment.\n\n### Exception or Error\n\n```text\nFailed to find a valid digest in the 'integrity' attribute for resource 'https://\u003chost>/chunk-z-ytF2G0.js' with computed SHA-384 integrity '\u003chash>'. The resource has been blocked.\n```\n\n### Your Environment\n\n```text\nAngular CLI : 22.2.5\nAngular : 22.2.3\nNode.js : 24.18.0\nPackage Manager : npm 11.16.0\nOperating System : darwin arm64\n\n┌───────────────────────────┬───────────────────┬───────────────────┐\n│ Package │ Installed Version │ Requested Version │\n├───────────────────────────┼───────────────────┼───────────────────┤\n│ @angular/build │ 22.2.5 │ ^22.2.2 │\n│ @angular/cli │ 22.2.5 │ ^22.2.2 │\n│ @angular/common │ 22.2.3 │ ^22.2.0 │\n│ @angular/compiler │ 22.2.3 │ ^22.2.0 │\n│ @angular/compiler-cli │ 22.2.3 │ ^22.2.0 │\n│ @angular/core │ 22.2.3 │ ^22.2.0 │\n│ @angular/forms │ 22.2.3 │ ^22.2.0 │\n│ @angular/platform-browser │ 22.2.3 │ ^22.2.0 │\n│ @angular/router │ 22.2.3 │ ^22.2.0 │\n│ rxjs │ 7.8.2 │ ~7.8.0 │\n│ typescript │ 6.0.3 │ ~6.0.2 │\n└───────────────────────────┴───────────────────┴───────────────────┘\n```\n\n### Anything else relevant?\n\nThis does not depend on the browser. Any cache in front of the hashed files can cause it.\n\nThe defect needs the chunk optimizer. With `NG_BUILD_OPTIMIZE_CHUNKS=false`, the same type change gives a new esbuild file name for the chunk (for example `chunk-P54LQIKA.js` to `chunk-5HS55H7R.js`), so the name and the bytes change together.\n\nA chunk that imports other chunks usually gets a new name anyway, because the names of the chunks it imports change. A chunk without such imports keeps its name.\n\nRelated: #33108, #33110, #33572. The current `main` still has this behavior: `injectDebugIds` (called from `execute-post-bundle.ts` when `sourcemapOptions.scripts` is true) changes the file contents but does not change the file name. The Rolldown pass in `chunk-optimizer.ts` uses `chunkFileNames: '\u003cname>-[hash].js'`.","author":{"url":"https://github.com/virgiliojr","@type":"Person","name":"virgiliojr"},"datePublished":"2026-10-28T16:37:46Z","url":"https://github.com/angular/angular-cli/issues/34574"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9b920311-3ff8-1fe4-204d-5ada63fc0144 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 90F4:269AD9:2F5E233:3F46437:6B01E019 |
| html-safe-nonce | 91b680889278aea31aa82d0596a69d7457faecf362b4c068050c45e9b3c17e5d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MEY0OjI2OUFEOToyRjVFMjMzOjNGNDY0Mzc6NkIwMUUwMTkiLCJ2aXNpdG9yX2lkIjoiMjc1OTg2OTAwNzUwNjAzODgwOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ae7f67d76e26cda8d63be32c515ca32147e2899f9c8e3da53b8d818c9d7ac8da |
| hovercard-subject-tag | issue:6083268189 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/34574/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eba32b5659191921c4e91d2f98961fcbc1551b3b0832bc00e1cb0e85bcb9f4d6/angular/angular-cli/issues/34574 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eba32b5659191921c4e91d2f98961fcbc1551b3b0832bc00e1cb0e85bcb9f4d6/angular/angular-cli/issues/34574 |
| og:image:alt | Command build Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was 22.0.x Description Since 22.1.0 (#33110), the ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | virgiliojr |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width