I've investigated this issue and it narrows down to a Safari bug that throws (for whatever reason) an "Internal Error" when accessing the cache.
The workaround has landed in 16.2.8
. If you see that issue update to at least this version.
As of today, no fix has landed in v14/v15.
Old answer :
There is a pending PR to add a workaround for the Safari bug.
Untils it gets merged and released you can add the workaround youself by editing /node_modules/@angular/service-worker/ngsw-worker.js
and adding a try/catch statement to the AssetGroup.handleFetch
method:
let cachedResponse: Response|undefined;
try {
// Safari 16.4/17 is known to sometimes throw an unexpected internal error on cache access
// This try catch is here as a workaround to prevent a failure of the handleFetch
// See #50378
cachedResponse = await cache.match(req, this.config.cacheQueryOptions);
} catch (error) {
throw new SwCriticalError(`Cache is throwing while looking for a match: ${error}`);
}
This change will log an error in the /ngsw/state
page when there is a cache issue.
You can persist this change in your repository using the patch-package
package.
Warning: This fix is only a workaround for the internal error. It will not fix the caching since there is an issue with Safari. I would invite the users to report that issue to the Safari team.
15.2.10
and16.2.8
to prevent that error. (caching will still be breaking though until Safari fixes their issue) ; – Unwary