-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Description
Command
build
Description
Currently, the Angular service worker does not provide adequate control and feedback mechanisms during the registration and caching process. This can lead to issues where developers are unable to detect if the service worker registration has failed or if the caching process has been successfully completed.
Example, right now I am unable to detect if the service worker registration failed. After inspection I found out that the navigator.serviceworker.register
code is present in main.js file generated after production build. The catch handler attached to the returned promise just consoles the error.
Also, there is no feedback about the caching of assets. The service worker is installed even if any asset could not be cached but some use cases might things to be handled a little differently.
Describe the solution you'd like
The ServiceWorker
module could provide some observables which emit such errors and feedback for registration failure, successful caching etc.,
Also more control over caching should be present because for some applications which are fully offline might require that all assets be cached before the Service worker installation is deemed successful.
Describe alternatives you've considered
Tried using the observables provided by SwUpdate service but realized that they don't work for the initial registration.
Tried using navigator.serviceworker.ready promise but this promise never rejects and will wait indefinitely to resolve until some SW is registered.