Service Worker doesn't get updated
Bug Report or Feature Request (mark with an x)
- [x ] bug report -> please search issues before submitting
Versions.
@angular/cli: 1.0.0 node: 6.3.1 os: win32 x64 @angular/animations: 4.3.6 @angular/cdk: 2.0.0-beta.10 @angular/common: 4.3.6 @angular/compiler: 4.3.6 @angular/core: 4.3.6 @angular/forms: 4.3.6 @angular/http: 4.3.6 @angular/material: 2.0.0-beta.10 @angular/platform-browser: 4.3.6 @angular/platform-browser-dynamic: 4.3.6 @angular/router: 4.3.6 @angular/service-worker: 1.0.0-beta.16 @angular/cli: 1.0.0 @angular/compiler-cli: 4.3.6
Repro steps.
Adding a service-worker to the project via @angular/serviceworker caches all designated files once. If I change to content of my files no new serviceworker is generated. This leads to a missing update of the cached files. They will never get updated unless pressing ctrl + F5
Desired functionality.
Changing the projects files should lead to a new generated serviceworker with a new timestamp on the next ng build --prod.
Don't know why but it's working now.
@ranbuch i'm seeing the exact same behavior as you outlined above, i've attempted a debug of notifyClientsAboutUpdate function and it seems that this code;
const version = this.clientVersionMap.get(client.id);
if (version === undefined) {
// Unmapped client - assume it's the latest.
return;
}
Is responsible for the swUpdate.available subscription not firing. @alxhub Can you explain why the clientVersionMap doesn't contain any entries when an update is detected?
Update:
Through some trial and error and many rebuilds of the app, it seems that just doing a rebuild with no code change, or just a TypeScript change does not result in a swUpdate.available.subscription firing as I would have expected. However (post-build) changing the name of a "dataGroups" object in ngsw.json, makes the subscription fire as expected.
Its worth noting that changing the "configVersion" of the ngsw.json file does not work as a way to test swUpdate.available observable.
This issue is still open, so does that mean that the snippet provided by @andreasonny83 is still needed? (after all it was provided in dec 2017) :)
This ticket has been open for a long time. I would love to have this resolved once and for all as well. Is that possible or will there always be potentials issues with 3rd party libraries?
As described in https://github.com/angular/angular-cli/issues/7665#issuecomment-351519025, the ServiceWorker will now check for updates on every navigation request (see angular/angular#21029). Closing, since the original issue has been resolved. (If you are still facing other problems, please open separate issues (if they are not reported already).)
We're actually using Angular 7.2.2 and Angular CLI 7.2.3 and we have an issue with this. I don't think it has been solved yet or maybe I am missing something. We followed https://angular.io/guide/service-worker-getting-started in order to setup the worker.
NOTE: we are using workbox in 3 others projects without any issue or extra code to check for update
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.