hotosm / tasking-manager

Tasking Manager - The tool to team up for mapping in OpenStreetMap
https://wiki.openstreetmap.org/wiki/Tasking_Manager
BSD 2-Clause "Simplified" License
505 stars 270 forks source link

[BUG] Service worker is stuck in the "trying to install" phase #5662

Open Aadesh-Baral opened 1 year ago

Aadesh-Baral commented 1 year ago

The issue is that after a new update, the service worker for the app is not installing properly and is stuck in the "trying to install" phase. This means that users will not be receiving the latest version of the app, even after performing a hard refresh (Ctrl+Shift+R).

Additionally, while the hard refresh successfully update the current page to the latest version, there is still the previous version of the app being loaded on other pages and in new tabs.

If the user opens a new tab after performing a hard refresh and the service worker is still not installed properly, they may still receive the previous version of the app in the new tab. This is because the browser may use the same service worker instance across different tabs. Therefore, if the service worker is not updated, it will still serve the old version of the app to the user in the new tab.

stuck_service_worker

HelNershingThapa commented 1 year ago

It appears that the behavior of cached files being served on new tabs, even after performing a hard refresh on the site, is expected behavior in line with my understanding of how service workers work. However, please note that I may be mistaken as I do not have extensive experience with service workers.

As per my analysis, when a service worker is active, a forced refresh will completely avoid it and provide content directly from the network instead. For this reason, when you merely refresh the page, you could see that some assets are delivered by the service worker, however, when you hard refresh the page, the assets are supplied from the network, resulting in the presentation of the most recent assets.

Asset is served from the network on hard refresh: netowkr-matrai

Asset is served by service worker on new tabs and on normal refresh: network-service-worker

Because the app uses an older service worker and the new service worker hasn't been enabled within that timeframe, the cached content is shown when viewing the same page in a new tab. Although this may give the impression that cached files continue to exist even after a hard refresh of the website, it is actually the result of service workers acting as planned.

Aadesh-Baral commented 1 year ago

@HelNershingThapa Thanks for the explanation. The installation of the service worker appears to take an excessive amount of time. Is this the expected time or should this be looked into?

HelNershingThapa commented 1 year ago

@Aadesh-Baral, It is possible that the relatively large build size of the app, with more assets to be downloaded and cached by the service worker, could contribute to longer installation times. The size and number of assets being precached during the installation process can impact the overall time it takes for the service worker to be installed and activated. However, it's also essential to consider other factors, such as network speed and the efficiency of the service worker implementation, to ensure that the installation time is reasonable and not excessively long.

@emi420, if you have anything additional to add, please feel free to do so. Otherwise, it seems reasonable to close this issue.

ramyaragupathy commented 4 months ago

@varun2948 @royallsilwallz @manjitapandey

ramyaragupathy commented 4 months ago

@HelNershingThapa's documentation of the issue: https://docs.google.com/document/d/1B1lbjHVSwjZ4wwt0_7RXJ-QBdMkr2EOT-sKG6GXyK30/edit