MCPcopy
hub / github.com/angular/angular / fetchLatestManifest

Method fetchLatestManifest

packages/service-worker/worker/src/driver.ts:931–946  ·  view source on GitHub ↗
(ignoreOfflineError = false)

Source from the content-addressed store, hash-verified

929 private async fetchLatestManifest(ignoreOfflineError?: false): Promise<Manifest>;
930 private async fetchLatestManifest(ignoreOfflineError: true): Promise<Manifest | null>;
931 private async fetchLatestManifest(ignoreOfflineError = false): Promise<Manifest | null> {
932 const res = await this.safeFetch(
933 this.adapter.newRequest('ngsw.json?ngsw-cache-bust=' + Math.random()),
934 );
935 if (!res.ok) {
936 if (res.status === 404) {
937 await this.deleteAllCaches();
938 await this.scope.registration.unregister();
939 } else if ((res.status === 503 || res.status === 504) && ignoreOfflineError) {
940 return null;
941 }
942 throw new Error(`Manifest fetch failed! (status: ${res.status})`);
943 }
944 this.lastUpdateCheck = this.adapter.time;
945 return res.json();
946 }
947
948 private async deleteAllCaches(): Promise<void> {
949 const cacheNames = await this.adapter.caches.keys();

Callers 2

initializeMethod · 0.95
checkForUpdateMethod · 0.95

Calls 5

safeFetchMethod · 0.95
deleteAllCachesMethod · 0.95
unregisterMethod · 0.80
jsonMethod · 0.80
newRequestMethod · 0.45

Tested by

no test coverage detected