WordPress / wordpress-playground

Run WordPress in the browser via WebAssembly PHP
https://w.org/playground/
GNU General Public License v2.0
1.58k stars 222 forks source link

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

Open adamziel opened 1 year ago

adamziel commented 1 year ago

https://github.com/WordPress/wordpress-playground/pull/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:

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

dmsnell commented 1 year ago

Seems fine.

brandonpayton commented 3 months ago

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.