Skip to content

The service worker v.20.2.0 freezes the browsers, works correctly with v20.1.0 #63500

Description

@meriturva

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:

  1. ng new application-name
  2. ng add @angular/pwa
  3. ng serve -c=production
  4. Open browser (Chrome 139.0.7258.155 on my side) and hit the refresh button
  5. 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)

Angular CLI: 20.2.1
Node: 22.18.0
Package Manager: npm 10.9.3
OS: win32 x64


Angular: 20.2.3
... common, compiler, compiler-cli, core, forms
... platform-browser, router, service-worker

Package                      Version
------------------------------------
@angular-devkit/architect    0.2002.1
@angular-devkit/core         20.2.1
@angular-devkit/schematics   20.2.1
@angular/build               20.2.1
@angular/cli                 20.2.1
@schematics/angular          20.2.1
rxjs                         7.8.2
typescript                   5.9.2
zone.js                      0.15.1

Anything else?

Deploy the application with version 20.1 to temporarily resolve the issue.

Activity

  1. added this to the needsTriage milestone on Aug 30, 2025
  2. SkyZeroZx commented on Aug 30, 2025

    @SkyZeroZx
    Contributor

    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:

    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.

  3. added
    needs: clarificationThis issue needs additional clarification from the reporter before the team can investigate.
    on Aug 30, 2025
  4. jvegaseg commented on Aug 31, 2025

    @jvegaseg

    I'm experiencing the same issue.

  5. meriturva commented on Aug 31, 2025

    @meriturva
    Author

    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?

  6. jvegaseg commented on Aug 31, 2025

    @jvegaseg

    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.

  7. meriturva commented on Aug 31, 2025

    @meriturva
    Author

    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?

  8. jvegaseg commented on Aug 31, 2025

    @jvegaseg

    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.

  9. jvegaseg commented on Sep 1, 2025

    @jvegaseg

    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:

    Image

    The value of event was:

    Image

    In another try, within ensureInitialized(), could be the problem here?:

    Image

    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
    
  10. meriturva commented on Sep 1, 2025

    @meriturva
    Author

    Same here using npx http-server on dist folder after ng build

    Image

    And on my dist folder there is no chunk-23PK7XQE.js

    Image

    I inspected more, and it happens when the cache storage is already present and an old version of "manifest".

    Image

    Basically, as I assumed on my first post, it happens only during the upgrade from an old version to the new one.

  11. unalkyl commented on Sep 2, 2025

    @unalkyl

    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.

  12. santiagof4 commented on Sep 2, 2025

    @santiagof4

    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.

    Image
  13. meriturva commented on Sep 5, 2025

    @meriturva
    Author

    @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.

  14. santiagof4 commented on Sep 5, 2025

    @santiagof4

    @meriturva I tried a lot of stuff and sadly the only solution so far is to downgrade to v20.1.8

  15. 10 remaining items

  16. MaksymPlotnikov commented on Oct 17, 2025

    @MaksymPlotnikov

    I had to remove all SW code and eagerly waiting for a fix from the Angular team...

  17. tmac12 commented on Oct 28, 2025

    @tmac12

    same problem also with v.20.3.7! Waiting for a fix

  18. atscott commented on Oct 28, 2025

    @atscott
    Contributor

    Is it possible to narrow this down further to a particular 20.2.0-next.# or 20.2.0-rc.# release?

  19. meriturva commented on Nov 11, 2025

    @meriturva
    Author

    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?

  20. atscott commented on Nov 11, 2025

    @atscott
    Contributor

    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.

  21. atscott commented on Nov 11, 2025

    @atscott
    Contributor

    6d01168 appears to be the culprit.

    Testing in the local app on main, the issue reproduces. Reverting the commit above resolves the issue.

  22. angular-automatic-lock-bot commented on Dec 12, 2025

    @angular-automatic-lock-bot

    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.

  23. locked and limited conversation to collaborators on Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: service-workerIssues related to the @angular/service-worker packageneeds: clarificationThis issue needs additional clarification from the reporter before the team can investigate.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions