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

Protocol for deploying playground.wp.net incompatible with the previous service worker #566

Closed
adamziel opened this issue Jun 18, 2023 · 3 comments

Comments

@adamziel
Copy link
Collaborator

#561 removed auto-refreshing of service workers as it wasn't working as expected and was also destructive.

The only problem remains deploying a website that is backwards–incompatible with the previous service worker.

Most backwards-incompatible changes can be avoided in one way or another.

Those that can't will need to ship with a service worker that forces a one-off skipWaiting() and reloads all served browser tabs.

The latter means reloading work-in-progress tabs for folks who:

  • Use Playground as that change is rolled out
  • Open a new Playground tab while the existing tabs are still active

Since that is a destructive action, let's make sure the new tab asks for permissions, e.g.

New Playground version was just released. You can continue using your current browser tabs, but if you need to open a new tab then Playground will reload ALL your currently open tabs. This will destroy your work in progress on all your temporary sites but won't affect your permanent sites. Would you like to proceed?

cc @dmsnell

adamziel added a commit that referenced this issue Jun 18, 2023
Removes the entire concept of detecting the service worker version and enforcing an update on mismatch.

Auto-reloading the service worker when it's updated thrashes any `postMessage` communication that's in progress at the moment of calling `skipWaiting()`. This causes Playground to hang at the "login" step in #559.

However, the browsers handle a lot by default:

* `registration.update()` method downloads the new service-worker.js file and compares it byte-by-byte with the existing one
* The previous service worker won't die until all the browser tabs it serves are closed
* The new service worker will automatically replace the previous one afterwards

The only problem remains deploying a website that is backwards–incompatible with the previous service worker. This is tracked separately in #566

Co-authored-by: Dennis Snell <dennis.snell@automattic.com>
adamziel added a commit that referenced this issue Jun 18, 2023
Removes the entire concept of detecting the service worker version and enforcing an update on mismatch.

Auto-reloading the service worker when it's updated thrashes any `postMessage` communication that's in progress at the moment of calling `skipWaiting()`. This causes Playground to hang at the "login" step in #559.

However, the browsers handle a lot by default:

* `registration.update()` method downloads the new service-worker.js file and compares it byte-by-byte with the existing one
* The previous service worker won't die until all the browser tabs it serves are closed
* The new service worker will automatically replace the previous one afterwards

The only problem remains deploying a website that is backwards–incompatible with the previous service worker. This is tracked separately in #566

Co-authored-by: Dennis Snell <dennis.snell@automattic.com>
@dmsnell
Copy link
Member

dmsnell commented Jun 19, 2023

Seems fine.

Pookie717 added a commit to Pookie717/wordpress-playground that referenced this issue Oct 1, 2023
Removes the entire concept of detecting the service worker version and enforcing an update on mismatch.

Auto-reloading the service worker when it's updated thrashes any `postMessage` communication that's in progress at the moment of calling `skipWaiting()`. This causes Playground to hang at the "login" step in WordPress/wordpress-playground#559.

However, the browsers handle a lot by default:

* `registration.update()` method downloads the new service-worker.js file and compares it byte-by-byte with the existing one
* The previous service worker won't die until all the browser tabs it serves are closed
* The new service worker will automatically replace the previous one afterwards

The only problem remains deploying a website that is backwards–incompatible with the previous service worker. This is tracked separately in WordPress/wordpress-playground#566

Co-authored-by: Dennis Snell <dennis.snell@automattic.com>
@adamziel adamziel added this to the Zero Crashes milestone Feb 29, 2024
@brandonpayton
Copy link
Member

brandonpayton commented Mar 19, 2024

I'm still learning about Service Workers, but it looks like we should be able to address this by using Clients.matchAll() to query for window clients and then use postMessage() to indicate we're asking the user to accept the upgrade.

@adamziel
Copy link
Collaborator Author

adamziel commented Oct 7, 2024

Let's track this in #1821

@adamziel adamziel closed this as not planned Won't fix, can't repro, duplicate, stale Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants