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
The service worker v.20.2.0 freezes the browsers, works correctly with v20.1.0 #63500
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:
ng new application-name
ng add @angular/pwa
ng serve -c=production
Open browser (Chrome 139.0.7258.155 on my side) and hit the refresh button
The browser is loading infinitely
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Unfortunately, the browser is frozen and there are no error messages. Only some requests remain pending.
Please provide the environment you discovered this bug in (run ng version)
EDIT :
Update: If you run it with ng serve -c=production , you might use something like this:
constswRegistrationOptions: 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.
Unfortunately, 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:4200 with ng 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 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 event was:
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:9
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.
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.
Activity
SkyZeroZx commentedon 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.155
EDIT :
Update: If you run it with ng serve -c=production , you might use something like this:
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.
jvegaseg commentedon Aug 31, 2025
I'm experiencing the same issue.
meriturva commentedon Aug 31, 2025
Unfortunately, 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:
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?
jvegaseg commentedon Aug 31, 2025
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.
meriturva commentedon Aug 31, 2025
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?
jvegaseg commentedon Aug 31, 2025
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.
jvegaseg commentedon Sep 1, 2025
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:
meriturva commentedon Sep 1, 2025
Same here using
npx http-serveron dist folder afterng buildAnd on my dist folder there is no
chunk-23PK7XQE.jsI 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.
unalkyl commentedon Sep 2, 2025
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.
santiagof4 commentedon Sep 2, 2025
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.
meriturva commentedon Sep 5, 2025
@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.
santiagof4 commentedon Sep 5, 2025
@meriturva I tried a lot of stuff and sadly the only solution so far is to downgrade to v20.1.8
10 remaining items
MaksymPlotnikov commentedon Oct 17, 2025
I had to remove all SW code and eagerly waiting for a fix from the Angular team...
tmac12 commentedon Oct 28, 2025
same problem also with v.20.3.7! Waiting for a fix
atscott commentedon Oct 28, 2025
Is it possible to narrow this down further to a particular
20.2.0-next.#or20.2.0-rc.#release?roger6106 commentedon Oct 28, 2025
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
20.2.0-next.3
20.2.0-next.2
meriturva commentedon Nov 11, 2025
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?
atscott commentedon Nov 11, 2025
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.
atscott commentedon Nov 11, 2025
6d01168 appears to be the culprit.
Testing in the local app on main, the issue reproduces. Reverting the commit above resolves the issue.
Revert "feat(service-worker): notify clients about version failures (a…
Revert "feat(service-worker): notify clients about version failures (a…
Revert "feat(service-worker): notify clients about version failures (#…
Revert "feat(service-worker): notify clients about version failures (#…
Revert "feat(service-worker): notify clients about version failures (#…
angular-automatic-lock-bot commentedon Dec 12, 2025
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.