MCPcopy
hub / github.com/angular/angular / versionFailed

Method versionFailed

packages/service-worker/worker/src/driver.ts:975–1006  ·  view source on GitHub ↗
(appVersion: AppVersion, err: Error)

Source from the content-addressed store, hash-verified

973 }
974
975 private async versionFailed(appVersion: AppVersion, err: Error): Promise<void> {
976 // This particular AppVersion is broken. First, find the manifest hash.
977 const broken = Array.from(this.versions.entries()).find(
978 ([hash, version]) => version === appVersion,
979 );
980
981 if (broken === undefined) {
982 // This version is no longer in use anyway, so nobody cares.
983 return;
984 }
985
986 const brokenHash = broken[0];
987
988 // The specified version is broken and new clients should not be served from it. However, it is
989 // deemed even riskier to switch the existing clients to a different version or to the network.
990 // Therefore, we keep clients on their current version (even if broken) and ensure that no new
991 // clients will be assigned to it.
992
993 // TODO: notify affected apps.
994
995 // The action taken depends on whether the broken manifest is the active (latest) or not.
996 // - If the broken version is not the latest, no further action is necessary, since new clients
997 // will be assigned to the latest version anyway.
998 // - If the broken version is the latest, the SW cannot accept new clients (but can continue to
999 // service old ones).
1000 if (this.latestHash === brokenHash) {
1001 // The latest manifest is broken. This means that new clients are at the mercy of the network,
1002 // but caches continue to be valid for previous versions. This is unfortunate but unavoidable.
1003 this.state = DriverReadyState.EXISTING_CLIENTS_ONLY;
1004 this.stateMessage = `Degraded due to: ${errorToString(err)}`;
1005 }
1006 }
1007
1008 private async setupUpdate(manifest: Manifest, hash: string): Promise<void> {
1009 try {

Callers 2

handleFetchMethod · 0.95
initializeMethod · 0.95

Calls 3

errorToStringFunction · 0.90
findMethod · 0.45
entriesMethod · 0.45

Tested by

no test coverage detected