spartacus
spartacus copied to clipboard
index.html hash mismatch in CCV2 Cloud when using pwa
Describe the bug When using the PWA feature of spartacus, a Service Worker is being installed in the user's client. Part of the Service Worker is the ngsw config, where we can define asset and data groups.
Part of the ngsw config in the dist folder is the hash table for all application dist files containing a hash based on the file content. This hash table is used by the service worker to distinguish, if there is an update or not.
This works for all assets except for the index.html file. The problem with the index html file is, that the file get's edited during the server startup in the CCV2 Cloud by the build script to inject the OCC Base url.
After that editing, the hash in the ngsw config does not match with the hash of the file anymore, since it's file content has changed.
This leads to a hash mismatch error in the service worker and the service worker / pwa does not work correctly anymore.
Tell us the version of Spartacus
- Library version: 6.5.1
To Reproduce Steps to reproduce the behavior:
- Create a fresh spartacus project
- Enable pwa
- Deploy it to the CCV2 Cloud
- Do a second deployment
- Check the page /ngsw/state
- Notice the hash mismatch error
Expected behavior
After the CCV2 Build changed the index.html file content, the ngsw hash table is regenerated. Use a tool like https://github.com/dev-jan/ngsw-rehash to regenerate it
Desktop (please complete the following information): all devices
Smartphone (please complete the following information): all devices
Additional context This is an issue of the CCV2 Cloud.
CXSPA-5788 created for it.