aspnetcore: Regression - PWA manifest version no longer varies
A while ago, we fixed https://github.com/dotnet/aspnetcore/issues/19882 by adding a hash to service-worker.js, computed by combining the hashes of all the files listed in the assets manifest, during publish.
Unfortunately it looks like our logic for this has regressed. During one of the refactorings related to precompression just before we released, we changed the metadata name from %(FileHash) to %(Integrity), but this line was not updated:
The result is that, instead of combining all the hashes, it now combines a set of empty strings, which results in another empty string, and then we hash that to produce a fixed value (47DEQpj8). Since this value never changes, the browser doesn’t try to fetch updates.
It’s troubling that this was not caught by tests. We do have build/publish tests that check that some hash was produced, but we can’t really check it’s the right hash without actually replicating all the build logic. What we should probably do is extend the build/publish test to publish once, then modify a source file, publish again, and verify that the hash actually changed. We do have some publish tests that do this kind of thing.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 18 (8 by maintainers)
Commits related to this issue
- fix: workaround for PWA manifest version updating via https://github.com/dotnet/aspnetcore/issues/22353 — committed to ant-design-blazor/ant-design-blazor by ElderJames 4 years ago
- fix: workaround for PWA manifest version updating (#227) via https://github.com/dotnet/aspnetcore/issues/22353 — committed to ant-design-blazor/ant-design-blazor by ElderJames 4 years ago
- ADD Quick fix while waiting for the release of https://github.com/dotnet/aspnetcore/issues/22353 — committed to vfabing/presentation-2020-06-BlazorDay by vfabing 4 years ago
- PWA version generation workaround (see https://github.com/dotnet/aspnetcore/issues/22353 ) setting app version for assemblies updated — committed to MichaelSL/blazor-wasm-test-012020 by MichaelSL 4 years ago
Just a note for anyone experiencing this issue - a workaround for now is simply to manually add a line to the end of the file
service-worker.published.jsand update it before you publish. e.g./* updated 2020-05-01 11:19 */This will be enough to trigger an update in the browser for now.It worked once, but is no longer working for the second time. This is very annoying, as there is no way of knowing if the App added on the Iphone Home Screen is the running the latest published version. In my case since there is a visual element change it is easy to figure out that it is not the latest one.
@akorchev Yes, we are planning to include a fix in the next patch release, whenever that happens. In the meantime you can use @SQL-MisterMagoo’s workaround above.