Skip to content
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

ServiceWorker doesn't update the app when going "back" to a previous version #8962

Open
MrCroft opened this Issue Dec 21, 2017 · 2 comments

Comments

Projects
None yet
5 participants
@MrCroft
Copy link

MrCroft commented Dec 21, 2017

Bug Report or Feature Request

- [x] bug report

Versions

Angular: 5.1.1
Angular CLI: 1.6.1

Repro steps

  1. Create an app (with ServiceWorker) using Angular CLI
  2. Build & Serve the app so the ServiceWorker initializes (let's say this would be version 1 of the app).
  3. Change anything in the app.
  4. Rebuild & Serve (let's say this is version 2 of the app).
  5. Access the app and then refresh to get the update.
  6. Undo the change you did at point (3) above.
  7. Rebuild & Serve.
  8. Access the app and try refreshing to get the update. Nothing happens. You're stuck on version 2 of the app.

Observed behavior

The v1 code is still cached after the update to v2. I guess because there is no notion of "this is the bundle for module X". Each file is simply... a file.
But it just doesn't go "back" to use the previously cached version after we undo some changes that generate the exact v1 bundles again (or some of them, anyway).

Desired behavior

Any change in the app code should trigger the update.

@MrCroft

This comment has been minimized.

Copy link
Author

MrCroft commented Dec 30, 2017

I've just tested again, after updating Angular to 5.1.2 and CLI to 1.6.3.
On the same app, it didn't occur anymore.
Thinking it's weird (as I didn't see anything in the changelog that might have affected this), I started to try out different scenarios.
I could only reproduce it under one circumstance:
If I opened developer tools any time after point (5), having them opened at point (8) when reloading the first time after the build, as expected the service worker doesn't update. But, after closing developer tools, it still didn't update until I closed the tab and reopen it or manually updating the service worker.

I think it's the same thing that happened initially. And what threw me off was that I expected things to go back to normal right away with the first refresh, after closing dev tools.
But, maybe things don't go back to the normal behavior the very second after closing developer tools, once you had it open.

So, it looks like wasn't a real issue and can be closed. Sorry for the trouble!

@XavierDupessey

This comment has been minimized.

Copy link

XavierDupessey commented Nov 30, 2018

related to angular/angular#24338?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.