Skip to content

SwUpdate checkForUpdate finishes too early on mobile devices #53867

@Catscratch

Description

@Catscratch

Which @angular/* package(s) are the source of the bug?

service-worker

Is this a regression?

No

Description

Hi community.

I want to be informed after all asset prefetching is complete by the service-worker. I'm using this to show a preloader as long as the application is still downloading assets.

In the ngsw-config.json I set

 "installMode": "prefetch",
 "updateMode": "prefetch",

for all the asset files I need (round about 50 MB).

In a service (started at application startup) I'm doing something like this:

if (this.swUpdate.isEnabled) {
  this.swUpdate.checkForUpdate().then(() => {
    // Here I will hide the preloader

    // This will be called AFTER all asset fetching is complete on nearly every desktop browser (Chrome, Edge, Firefox).
    // But this will be called BEFORE asset fetching is complete (assets still loading) on Android (Chrome, Edge)
  });
}

According to the documentation of checkForUpdate it should wait until fetching is complete:
Checks for an update and waits until the new version is downloaded from the server and ready for activation.

So my question: Is this a bug or do I have a wrong understanding of how that works?

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 16.2.10
Node: 18.16.1
Package Manager: npm 9.7.2
OS: win32 x64

Angular: 16.2.12
... animations, cdk, common, compiler, compiler-cli, core, forms
... material, material-date-fns-adapter, platform-browser
... platform-browser-dynamic, router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1602.10
@angular-devkit/build-angular   16.2.10
@angular-devkit/core            16.2.10
@angular-devkit/schematics      16.2.10
@angular/cli                    16.2.10
@angular/fire                   7.6.1
@angular/pwa                    16.2.10
@schematics/angular             16.2.10
rxjs                            7.8.1
typescript                      4.9.5
zone.js                         0.13.3

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: service-workerIssues related to the @angular/service-worker package

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions