Visitar URL original
checkForUpdate never resolved in production (13.0.0) · Issue #44044 · angular/angular · GitHub
The Wayback Machine - https://web.archive.org/web/20250518194419/https://github.com/angular/angular/issues/44044
Skip to content

checkForUpdate never resolved in production (13.0.0) #44044

Closed
@Enngage

Description

@Enngage

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

service-worker

Is this a regression?

Yes

Description

Hey,

I'm trying to determine if new update is available, but for some reason, in following code:

    constructor(appRef: ApplicationRef, private swUpdate: SwUpdate) {
        if (this.swUpdate.isEnabled) {
            const appIsStable$ = appRef.isStable.pipe(first((isStable) => isStable === true));
            const intervalObs$ = interval(30* 1000);
            const stableIntervalObs$ = concat(appIsStable$, intervalObs$);
            stableIntervalObs$.subscribe(() => {
                swUpdate.checkForUpdate().then(response => {
                     // This is never hit
                });
            });
        }
    }

The swUpdate.checkForUpdate is never resolved. Strangely, this happens only in production mode. It works perfectly fine when tested locally with service worker & HTTP server. It should return true / false depending on whether a new update is available, but it never returns anything. Really no idea why it works like a charm locally, but not on production. (I've tried clearing cache, removing service worker, anonymous window and all the usual stuff)

In network tab I can see that the ngsw.json?ngsw-cache-bust=0.0010572762505560718 is being hit as expected (every 30 sec in my case), however the timestamp is the same for all requests.

Can you guys think of any reason the checkForUpdate would never resolve on production? Is there something I can test / check?

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

Angular 13.0.0

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