You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem I encounter is that after the service worker has been updated 2 times without the user reloading my app, I'm not receiving an event when the service worker is updated for the 3rd time, and hence I don't know where to send the skip waiting event to.
Scenario:
App is running, only open in 1 tab
Service worker is updated
App receives the waiting event and handle to new SW
App displays non blocking reload prompt
User does not reload
Service worker is updated again
App receives the externalwaiting event and handle to new SW
App is still displaying non blocking reload prompt
User does not reload
Service worker is updated again
App does not receive waiting or externalwaiting event, and of course not the handle to the new SW
App is still displaying non blocking reload prompt
User tries to reload through prompt
Since the app does not have the handle for the most recent SW, nothing happens
I've found a workaround that works for me reliably. Storing the registration object from register and then sending the message to the registration.waiting SW.
Library Affected:
workbox-window
Browser & Platform:
all browsers
Issue or Feature Request Description:
I'm basically following this recipe: https://developers.google.com/web/tools/workbox/guides/advanced-recipes#offer_a_page_reload_for_users
The prompt that is offered to the user is not blocking, so the user can keep working without updating immediately.
The problem I encounter is that after the service worker has been updated 2 times without the user reloading my app, I'm not receiving an event when the service worker is updated for the 3rd time, and hence I don't know where to send the skip waiting event to.
Scenario:
App receives the waiting event and handle to new SW
App displays non blocking reload prompt
User does not reload
App receives the externalwaiting event and handle to new SW
App is still displaying non blocking reload prompt
User does not reload
App does not receive waiting or externalwaiting event, and of course not the handle to the new SW
App is still displaying non blocking reload prompt
Since the app does not have the handle for the most recent SW, nothing happens
The change from waiting to externalwaiting event is caused by _updateFoundCount.
Not a problem, but it doesn't make sense to me, looks like the code only ever expects 1 waiting update.
https://github.com/GoogleChrome/workbox/blob/master/packages/workbox-window/src/Workbox.ts#L347
The reason for the missing externalwaiting event on the 3rd update is that the updatefound event listener is removed when the first "external" event is encountered:
https://github.com/GoogleChrome/workbox/blob/master/packages/workbox-window/src/Workbox.ts#L363
Commenting out that line fixed my problem.
The text was updated successfully, but these errors were encountered: