8000 Service Worker always generates a new version hash even if source files did not change · Issue #61297 · angular/angular · GitHub
[go: up one dir, main page]

Skip to content

8000 Service Worker always generates a new version hash even if source files did not change #61297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SebastianPost1996 opened this issue May 13, 2025 · 1 comment
Labels
area: service-worker Issues related to the @angular/service-worker package
Milestone

Comments

@SebastianPost1996
Copy link
SebastianPost1996 commented May 13, 2025

Which @angular/* package(s) are the source of the bug?

service-worker

Is this a regression?

No

Description

From the Service Worker Documentation:

The version identifier of the application is determined by the contents of all resources, and it changes if any of them change. In practice, the version is determined by the contents of the ngsw.json file, which includes hashes for all known content. If any of the cached files change, the file's hash changes in ngsw.json. This change causes the Angular service worker to treat the active set of files as a new version.

Assuming that the refered hash is the one included in VersionReadyEvent.latestVersion.hash, this is currently not the case. From my testing, each build results in a new version hash even if a) the build hash is the same and b) the hashTable of ngsw.json is the same. (So effectively, the only thing that changes in ngsw.json is the timestamp property)

This in turn causes SwUpdate to detect unnecessary updates with no changes.

Update:
As I suspected it is the timestamp in ngsw.json that is affecting the version hash. Removing the timestamp or setting it to a fixed value in the built app will result in the versioning working as documented.

@coder-ashwin
Copy link

I had the same issue, but this was not replicable for the angular team so they need a minimum reproduction through stackblitz or something, I didn't get time to do it. If you have time, can you add that otherwise this won't get picked up just like mine I think angular/angular-cli#30064

@thePunderWoman thePunderWoman added the area: service-worker Issues related to the @angular/service-worker package label May 16, 2025
@ngbot ngbot bot added this to the needsTriage milestone May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: service-worker Issues related to the @angular/service-worker package
Projects
None yet
Development

No branches or pull requests

3 participants
0