Repository navigation
The service worker v.20.2.0 freezes the browsers, works correctly with v20.1.0 #63500
Description
Activity
- addedarea: service-workerIssues related to the @angular/service-worker packageIssues related to the @angular/service-worker package
on Aug 30, 2025 In my case I have a demo application with PWA and SSR in Angular 20.2.3, you can see the repository here I just updated it
Repo : https://github.com/SkyZeroZx/ng-ssr-twa-adaptive
App Deployed in Vercel : https://ng-ssr-twa-adaptive.vercel.app/
It works well for me
Chrome Version : 139.0.7258.155EDIT :
Update: If you run it with ng serve -c=production , you might use something like this:const swRegistrationOptions: SwRegistrationOptions = { enabled: !isDevMode(), // Register the ServiceWorker as soon as the application is stable // or after 30 seconds (whichever comes first). registrationStrategy: 'registerWhenStable:30000' };
It stays loaded indefinitely because you try to enable the service worker. In my experience, I remember you can never enable it in development mode because it "freezes." In my case, it works if I use https://www.npmjs.com/package/http-server, as far as I remember.
The app deployed in production under HTTPS that I mentioned above works.
- addedneeds: clarificationThis issue needs additional clarification from the reporter before the team can investigate.This issue needs additional clarification from the reporter before the team can investigate.
on Aug 30, 2025 I'm experiencing the same issue.
Reacted by Gaëtan Cottrez and Volodymyr KornetskyiUnfortunately, this issue is very difficult to reproduce, and I suspect it is related to the update of the service worker from a previous version to the latest one. In particular, to work around the problem, I released a version of my enterprise application without enabling the service worker.
Additionally, I included a very simple JS script to remove the service worker:navigator.serviceWorker.getRegistrations().then(registrations => { for (const registration of registrations) { registration.unregister(); } });When the issue occurs, my clients’ browsers get stuck for about 30 seconds (waiting for a timeout), after which the application loads correctly and then executes the instructions to “unregister” service worker. Now, without any service worker, application runs as expected.
Only in this way was I able to provide a solution to all the complaints I received in recent days (I spent days investigating the server because I thought it was a network issue, but in the end, I believe it’s a combination of conditions between an old version of ngsw-worker.js and its update to the new version v.20.2).On same time, i spent a lot of time trying to simulate the issue with a clean project and http-server without any success.
What about your project @jvegaseg ? Did you find a way to easily replicate the issue?
I am attempting to isolate the issue, but I cannot obtain any logs because the browser freezes. In my case, when I try to access the application using
localhost:4200withng serve, the browser consistently freezes.If I cancel the request (using the stop button in the browser) and perform a hard reload with Ctrl+Shift+R, the application loads successfully. However, when I subsequently refresh the page, it freezes again. If I cancel once more and perform another hard reload, the page loads successfully again.
This behavior is quite unusual, and I will continue investigating.
What I have noted is that if you clear all site service workers and cache using, for example, DevTools -> Application -> Storage -> "Clear site data" everything starts to work again. Another test, quite simple, is to start the application using a different network port (a random one), so you can start with a service worker from the latest package version. @jvegaseg Could you please try?
I have already tried the following:
-
Clear site data: it does not resolve the issue.
-
Change the network port: it works the first time I use that port, but then the same problem occurs again.
-
I was able to set a breakpoint in the service worker (ngsw-worker.js). The code consistently halts at line 1803, at
await this.ensureInitialized(event);, and it never resumes from there:
The value of
eventwas:
In another try, within ensureInitialized(), could be the problem here?:
Where error was:
SwCriticalError: Hash mismatch (cacheBustedFetchFromNetwork): http://localhost:4200/action.component-J6KFWARO.js: expected 05347f5e20eacab9f783f81475e5e090a8884c2a, got fa578afc4dace3ec0cb6f16496f86836ad1a1eac (after cache busting) at PrefetchAssetGroup.cacheBustedFetchFromNetwork (ngsw-worker.js:578:21) at async PrefetchAssetGroup.fetchFromNetwork (ngsw-worker.js:550:19) at async PrefetchAssetGroup.fetchAndCacheOnce (ngsw-worker.js:529:21) at async ngsw-worker.js:657:9 at async ngsw-worker.js:643:9 at async ngsw-worker.js:643:9 at async ngsw-worker.js:643:9 at async ngsw-worker.js:643:9 at async ngsw-worker.js:643:9 at async ngsw-worker.js:643:9Same here using
npx http-serveron dist folder afterng build
And on my dist folder there is no
chunk-23PK7XQE.js
I inspected more, and it happens when the cache storage is already present and an old version of "manifest".
Basically, as I assumed on my first post, it happens only during the upgrade from an old version to the new one.
Same here. The application starts working when I unregister the service worker. Then, after a few minutes, I see the browser start to reload and the application crashes again.
We have the very same issue in our app after upgrading to Angular 20.2. Weirdly, the most reliable way to reproduce it is to close the browser entirely, opening it again and then try to open our app. The app gets stuck loading, in the devtools' network tab the very first request stays stuck pending. As far as we can tell, only Chromium based browsers are affected, even our Electron app is affected by the very same issue.
The only way to recover from this is to either unregister the service worker, or to refresh the page, but then it eventually happens again, or immediately after the browser get closed and opened again.
Reacted by roger6106@santiagof4 did you find a way to make v20.2 work with service worker? I had to disable the service and a few features to make my app work again.
@meriturva I tried a lot of stuff and sadly the only solution so far is to downgrade to v20.1.8
Reacted by Diego Bonura, jvegaseg and roger610610 remaining items
I had to remove all SW code and eagerly waiting for a fix from the Angular team...
Reacted by Diego Bonura, graybushlabs, dfaliush, jvegaseg, Adrian Kunz and jbpzensame problem also with v.20.3.7! Waiting for a fix
Is it possible to narrow this down further to a particular
20.2.0-next.#or20.2.0-rc.#release?I have not narrowed it down, but it may be beneficial to do that. Here are the specific changes listed as affecting the service worker:
20.2.0-rc.0
20.2.0-next.4
- feat(service-worker): add messageerror event handling and logging #62834
- feat(service-worker): Adds for type in provideServiceWorker #62831
20.2.0-next.3
- feat(service-worker): Improves storage full detection in data caching #62737
- feat(service-worker): notify clients about version failures #62718
20.2.0-next.2
My apps, unfortunately still running with service workers disabled. What about the new upcoming Angular version 21.x? I don't see any updates related to that issue, am I wrong?
I have observed that this works in 20.2.0-next.2 but is broken in 20.2.0-next.3. More work needs to be done to narrow down the issue further to an individual commit, if possible.
Reacted by Maksym Plotnikov and Diego Bonura6d01168 appears to be the culprit.
Testing in the local app on main, the issue reproduces. Reverting the commit above resolves the issue.
Reacted by Maksym Plotnikov, roger6106, Diego Bonura and Julian Holfeld- added a commit that references this issue
on Nov 11, 2025 angular-automatic-lock-bot commented
on Dec 12, 2025 More actionsThis 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.
- locked and limited conversation to collaborators
on Dec 12, 2025
Which @angular/* package(s) are the source of the bug?
service-worker
Is this a regression?
No
Description
The issue is quite simple, and also easy to reproduce: the new implementations on v20.2 added to the service worker cause abnormal behavior, blocking the site from loading, especially during a page refresh.
How to reproduce:
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version)Anything else?
Deploy the application with version 20.1 to temporarily resolve the issue.