{"record":{"id":"91463f2d6e53c2d9","repo":"angular/angular","slug":"cache-is-throwing-while-looking-for-a-match-err","errorCode":null,"errorMessage":"Cache is throwing while looking for a match: ${error}","messagePattern":"Cache is throwing while looking for a match: (.+?)","errorType":"exception","errorClass":"SwCriticalError","httpStatus":null,"severity":"error","filePath":"packages/service-worker/worker/src/assets.ts","lineNumber":143,"sourceCode":"    // order to decide how to handle it.\n    if (this.urls.indexOf(url) !== -1 || this.patterns.some((pattern) => pattern.test(url))) {\n      // This URL matches a known resource. Either it's been cached already or it's missing, in\n      // which case it needs to be loaded from the network.\n\n      // Open the cache to check whether this resource is present.\n      const cache = await this.cache;\n\n      // Look for a cached response. If one exists, it can be used to resolve the fetch\n      // operation.\n      let cachedResponse: Response | undefined;\n      try {\n        // Safari 16.4/17 is known to sometimes throw an unexpected internal error on cache access\n        // This try/catch is here as a workaround to prevent a failure of the handleFetch\n        // as the Driver falls back to safeFetch on critical errors.\n        // See #50378\n        cachedResponse = await cache.match(req, this.config.cacheQueryOptions);\n      } catch (error) {\n        throw new SwCriticalError(`Cache is throwing while looking for a match: ${error}`);\n      }\n\n      if (cachedResponse !== undefined) {\n        // A response has already been cached (which presumably matches the hash for this\n        // resource). Check whether it's safe to serve this resource from cache.\n        if (this.hashes.has(url)) {\n          // This resource has a hash, and thus is versioned by the manifest. It's safe to return\n          // the response.\n          return cachedResponse;\n        } else {\n          // This resource has no hash, and yet exists in the cache. Check how old this request is\n          // to make sure it's still usable.\n          if (await this.needToRevalidate(req, cachedResponse)) {\n            this.idle.schedule(`revalidate(${cache.name}): ${req.url}`, async () => {\n              await this.fetchAndCacheOnce(req);\n            });\n          }\n","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/angular/angular/blob/51cb07e98081ab7e4e84a9e0949266a8e19cca84/packages/service-worker/worker/src/assets.ts#L125-L161","documentation":"Inside the Angular service-worker script, serving a cached request requires cache.match() on CacheStorage; when that API itself throws (a known Safari 16.4/17 internal-error bug, or corrupted/evicted storage) the SW wraps it in SwCriticalError. The Driver catches critical errors and falls back to a safe network fetch, so requests still succeed but nothing is served from cache until the SW recovers.","triggerScenarios":"A Safari 16.4/17.x browser performs a cache lookup during handleFetch and the Cache API throws internally (angular/angular#50378); or storage corruption/quota eviction makes cache.match() reject in any browser.","commonSituations":"PWA bug reports from Safari 16.4/17 users, especially on Angular versions predating the try/catch workaround; DevTools 'Clear site data' executed while the SW keeps serving another tab.","solutions":["Update Angular to a version that includes the Safari workaround (the try/catch around cache.match added for #50378).","Have affected users unregister the service worker and clear storage once, then reload to install a fresh SW.","If it persists across users, bump the app version in ngsw-config.json to force a clean reinstall."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Stay on an Angular version containing the Safari cache.match workaround (#50378).","Expose a 'reset offline cache' action that unregisters the SW and clears caches, for users hitting corrupt cache state.","Monitor SwUpdate errors / SW logs in production to catch cache failures per browser version."],"tags":["service-worker","cache-storage","safari","sw-critical-error","offline"],"backgroundTag":"cache-storage-error","analyzedSha":"51cb07e98081ab7e4e84a9e0949266a8e19cca84","analyzedAt":"2026-08-22T07:04:54.531Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}