Skip to content

SwUpdate Methods lead to degraded Mode when service worker is stopped #32095

@alexion4

Description

@alexion4

🐞 bug report

Affected Package

The issue is caused by package @angular/service-worker

Is this a regression?

Probably not

Description

When SwUpdate::checkForUpdate() or SwUpdate::activateUpdate() is called while the service worker is stopped, the service worker enters a degraded state.

The likely cause is that the Driver is not initialized is this case. (Driver::initialize() is never called)

🔬 Minimal Reproduction

Reproduction is possible with the example code from the angular docs:
https://angular.io/guide/service-worker-communications

Just make sure that the service worker is stopped (by the browser after some idle time or manually with chrome dev tools) before the methods are called

🔥 Exception or Error

For checkForUpdates() this is the ngsw/state after the call:


NGSW Debug Info:

Driver state: EXISTING_CLIENTS_ONLY (Degraded due to failed initialization: Cannot read property 'previouslyCachedResources' of undefined
TypeError: Cannot read property 'previouslyCachedResources' of undefined
    at Driver. (https://example.com/ngsw-worker.js:2624:32)
    at Generator.next ()
    at fulfilled (https://example.com/ngsw-worker.js:1787:62))
Latest manifest hash: none

🌍 Your Environment

Angular Version:


Angular CLI: 8.2.1
Node: 10.15.2
OS: linux x64
Angular: 8.2.1
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.802.1
@angular-devkit/build-angular     0.802.1
@angular-devkit/build-optimizer   0.802.1
@angular-devkit/build-webpack     0.802.1
@angular-devkit/core              8.2.1
@angular-devkit/schematics        8.2.1
@angular/pwa                      0.802.1
@ngtools/webpack                  8.2.1
@schematics/angular               8.2.1
@schematics/update                0.802.1
rxjs                              6.5.2
typescript                        3.5.3
webpack                           4.39.1

Browser:
Chromium 76.0.3809.87

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions