You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
@angular/build 22.1.4+: new modulepreload hints for shared chunks are discarded by Chrome ("cross-world service worker resource mismatch") when served by @angular/service-worker #34022
Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
22.1.3
Description
Since 22.1.4, shared chunks get <link rel="modulepreload"> hints, which Chrome discards with a "cross-world service worker resource mismatch" warning when ngsw serves them
Which @angular/ package(s) are the source of the bug?*
@angular/build (application builder) — behaviour change introduced by #33793 (22.1.4 backport 46fcb29).
#33793 fixed the chunk optimizer so that statically imported shared chunks are stored in initialFiles (previously the record was created but never set). A side effect not mentioned in the PR: index-html-generator now emits up to MODULE_PRELOAD_MAX (10) <link rel="modulepreload"> hints for those chunks. Before 22.1.4 our production index.html had 0 such hints; from 22.1.4 it has 10, with identical application code (bisected commit by commit, building with ng build --configuration production).
When the app is served by the Angular service worker (@angular/service-worker, assetGroup app in prefetch mode), every repeat visit where the SW already controls the page logs one warning per hint in Chrome:
A preload for 'https:///chunk-XXXX.js' is found, but is not used because it is a cross-world service worker resource mismatch.
The preload is fetched from the network by the document while the real module request is answered by the service worker from Cache Storage, so Chrome discards the preloaded response. Net effect on repeat visits with an active SW: the preloaded bytes are downloaded and thrown away.
Minimal Reproduction
ng new with --ssr false, add @angular/service-worker (ng add @angular/service-worker), keep the default ngsw-config.json.
Add enough lazy routes sharing common code so the chunk optimizer runs (>= optimizeChunksThreshold, default 3 lazy chunks) and produces shared chunks statically imported by initial code.
ng build --configuration production with @angular/build@22.1.3 → index.html has no modulepreload; with 22.1.4 → N modulepreload links.
Serve dist/, load twice so the SW controls the page, open DevTools console → warnings above.
Exception or Error
> A preload for 'https://<host>/chunk-XXXX.js' is found, but is not used because it is a cross-world service worker resource mismatch.
Either the optimizer should not mark SW-served shared chunks as preload candidates, or the docs should point out that apps using @angular/service-worker should set "index": { "input": "src/index.html", "preloadInitial": false } to avoid redundant downloads and console noise. Alternatively, preloadInitial could default to false when the build includes a service worker (serviceWorker option set).
Activity
fix(@angular/build): default preloadInitial to false when serviceWork…
fix(@angular/build): default preloadInitial to false when serviceWork…
angular-automatic-lock-bot commentedon Oct 21, 2026
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.