-
Notifications
You must be signed in to change notification settings - Fork 175
Potential cache corruption from service worker #150
Comments
same here =/ |
@Ploppy3 Yes. According the plan, there will be an updated version (as a part of the core) in Angular 5 (which is quite soon) |
@webmaxru Will it be possible to upgrade from the current version to the version integrated to Angular ? |
Refactoring will mainly affect ngsw-manifest (to make the settings and flow more flexible, consistent, universal). I don't have the information about upgrade: it could be backward compatibility mode or upgrade script. Anyway - this manifest is a simple json file, updating its format shouldn't be an issue even in manual mode. |
@webmaxru I just tested and the new version does not seem to be retro-compatible, is there a solution? |
It seems like you are working on it. |
@Ploppy3 you are right, the "old" NGSW (beta 1-16) is not compatible with the release version. They share the same idea, but the configuration files and flow are a bit different. Quickstart: https://www.youtube.com/watch?v=wFjw0DM1ui4 |
@Ploppy3 Which version of Angular and Angular CLI do you use for your project? I don't think there will be a migration script/util for NGSW just because after all it's a question of slightly modified JSON configuration. It's really simple to update it manually. |
I'm not sure but I may I have explained it poorly. Let me reiterate. I don't have any problem upgrading my code to the new service-worker. My problem is that the new service-worker seems incompatible with the old one and the new version of the app is never loaded nor installed. (I'm using latest CLI & Angular) |
@webmaxru Here are the files generated by the 'old' service-worker. These are the files generated by the 'new' service-worker script: Just to be clear. At this point, if I upload the new app, the old service-worker will start because the old app is cached. Then, it will look for the ngsw-manifest.json, which it can't find because the new one uses a different file name, so a 404 is thrown and update is aborted. I'm not sure what to do to make the old one update to the new one. Or maybe I need a script to uninstall the old service worker but I have no idea how to it. |
@webmaxru I found this angular/angular@db3e65f |
@Ploppy3 If I understand correctly, the issue is:
In that case, you might want to serve a "kill switch" instead of worker-basic.min.js. Have a look at its contents here: https://stackoverflow.com/a/38980776/1310228 |
@webmaxru I attempted this in local and it seems to work. I will confirm later. |
I noticed a problem on Chrome Android only, no matter the Android version nor Chrome version, the service worker will mess up the cache somehow. I tried for days to identify the issue but I'm unsuccessful. It could be an error on my side though, I could be missing a critical step.
Tested on Chrome on 3 devices, running different versions of Android, and tested on my device on 4 versions of Chrome (all the available branches). Version of the SW is 1.0.0-beta.13. I thought you fixed the bug in this release but it is still present.
As I can't debug my Android devices (a bit of laziness and lack of USB-C adapter 😄 ) I can only guess what the issue is. I think it's due to cache failure when the service worker caches the index.html into other critical .js files due to redirection.
I have 4 apps using the service worker all have the same problems. So I ended up creating the most simple app. An empty app with just the service worker which shows a number representing the app version and a text to warn when an update is installed in the background.
The thing I noticed, there are 2 ways to reproduce the bug:
These steps in image (Chrome Canary 60.0.3097.0):
In both cases, if you reload the app after the crash it will load but weird behaviors may appear such as version rollbacks (that's why I think it's related to the cache).
The test app is available here: https://test-service-worker-97321.firebaseapp.com/ (current version is 19)
I can update it whenever you ask. For you to test as well.
Here is the code of the sample app:
ngsw-manifest.json
app.module.ts
app.component.ts
app.component.html
The text was updated successfully, but these errors were encountered: