New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Service worker does not fetch new version of the app if the version is same as a previous version #24338
Comments
Indeed, this happens due to this check: angular/packages/service-worker/worker/src/driver.ts Lines 773 to 776 in e0ed59e
I guess this is to account for proxies serving outdated content or something. (Taking this one step further, it would be even better if we kept the "uid" distinct from the hash, so that we could detect that the latest version is identical with a previous one and re-use that without having to re-fetch assets (even if from cache).) |
…o an old one Previously, if an app version contained the same files s an older version (e.g. making a changing, then rolling it back), the SW would not detect it as the latest version (and update clients). This commit fixes it by adding a `timestamp` field in `ngsw.json`, which makes each build unique (with sufficiently high probability). Fixes angular#24338
…o an old one Previously, if an app version contained the same files s an older version (e.g. making a changing, then rolling it back), the SW would not detect it as the latest version (and update clients). This commit fixes it by adding a `timestamp` field in `ngsw.json`, which makes each build unique (with sufficiently high probability). Fixes angular#24338
…o an old one Previously, if an app version contained the same files as an older version (e.g. making a change, then rolling it back), the SW would not detect it as the latest version (and update clients). This commit fixes it by adding a `timestamp` field in `ngsw.json`, which makes each build unique (with sufficiently high probability). Fixes angular#24338
@gkalpak do you have any recommendations on how to fix this meanwhile your PR gets merged? My Angular service worker doesn't seem to recognize app updates if I roll back to an older version of the app I am working on. I'm new to PWA's so any advice would be greatly appreciated |
Unfortunately, I can't think of any work around that would allow rollbacks to work. The obvious (but tedious) solution is to change something in |
Bug still exists in Angular 7.1.1. The workaround suggested by @gkalpak works: change anything in ngsw-config.json (ngsw.json in dist folder) > appData. Thanks ! |
…o an old one Previously, if an app version contained the same files as an older version (e.g. making a change, then rolling it back), the SW would not detect it as the latest version (and update clients). This commit fixes it by adding a `timestamp` field in `ngsw.json`, which makes each build unique (with sufficiently high probability). Fixes angular#24338
If anyone deploys the app with CI/CD, you can use it to replace properties in ngsw.json to make this work like what @gkalpak suggested. Here is how to do it in Azure DevOps add variables like because deploymentId will change when there is a deployment every time, so it can make rollback work properly. |
…o an old one Previously, if an app version contained the same files as an older version (e.g. making a change, then rolling it back), the SW would not detect it as the latest version (and update clients). This commit fixes it by adding a `timestamp` field in `ngsw.json`, which makes each build unique (with sufficiently high probability). Fixes angular#24338
…o an old one (#26006) Previously, if an app version contained the same files as an older version (e.g. making a change, then rolling it back), the SW would not detect it as the latest version (and update clients). This commit fixes it by adding a `timestamp` field in `ngsw.json`, which makes each build unique (with sufficiently high probability). Fixes #24338 PR Close #26006
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a...
Current behavior
I build a sample hello world project with angular cli and add service worker. And i added update handler on my main project to show some notification. Lets say this is version A. I did a prod build and all is well. I changed to style css lets say body {background:red} and i build again (version B) while http-server is still up. I refreshed page and service worker catched the diff and show the notication.So far so good,
Then i reverted css change and end up with a version C which is identical to version A in terms on file contents.
Then build and deploy again. At this time when i refresh the app, the service worker doesnt fetch the new files and still show the version B.
Expected behavior
Service worker should fetch the version C and trigger an update showing notification
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Sometimes developers make a rollback after a detecting a fatal bug after a new release. With this bug, the revert wont go use
Environment
The text was updated successfully, but these errors were encountered: