Repository navigation
Description
Which @angular/* package(s) are the source of the bug?
service-worker
Is this a regression?
Yes
Description
I run an Angular application with version 14.2, and I encouter problems with Safari on iPhones and iPads running 16.4 or higher.
The issue I'm having is that my application sometimes (really sometimes) shows the white page of death and sometimes Safari shows the Error: 'FetchEvent.respondWith received an error: TypeError: Internal error' without any further information. The app uses the angular service worker (for PWA support) and from what I have read on earlier issues with this kind of error, it might be cache related. Reloading the page solves this issue.
I'm really clueless at the moment how I can even work around this problem.
EDIT:
I was able to reproduce it on angular.io after a lot of refreshes on my Mac:
(Message is in dutch, saying it can't load the page)
So it seems like there is some bug with the service worker in combination with Safari in general.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
FetchEvent.respondWith received an error: TypeError: Internal error
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 14.2.11
Node: 16.10.0
Package Manager: npm 7.24.0
OS: win32 x64
Angular: 14.2.7
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
... service-worker
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1402.11
@angular-devkit/build-angular 14.2.11
@angular-devkit/core 14.2.11
@angular-devkit/schematics 14.2.11
@angular/cdk 14.2.5
@angular/cli 14.2.11
@schematics/angular 14.2.11
rxjs 7.5.7
typescript 4.7.4
Anything else?
No response
Activity
AMO-brandon commentedon May 24, 2023
We have also encountered this issue. We are on angular 13, any ETA on a fix?
AMO-brandon commentedon May 30, 2023
bump
Yang-LiYing commentedon Aug 3, 2023
We also encountered the same error message while accessing the PWA application of Angular 14 on an iPhone 17 device. During the debugging process, we noticed that the error might be related to issues with the Cache API invocation. Therefore, we addressed this problem by making modifications to the ngsw-worker.js file, adding error catching or reject callbacks to the part of the code that handles Cache API calls. As a result, we were able to resolve the issue. However, we acknowledge that this might not be the optimal solution and is just one approach we tried. We hope this feedback provides some additional insights for consideration.
This is the error we captured during the service worker runtime.
davisriska commentedon Aug 7, 2023
I'm also seeing this error on safari(16.6 (18615.3.12.11.2)) after updating from 16.3 (18614.4.6.1.6) where I didn't get this error. Anyone know a workaround for this? I'm getting this on a production environment so my ass is on fire for this.
For me it happens right after an auth mechanism which is similar to oauth with redirects. And when the redirect happens to my app it shows the
FetchEvent.respondWith ..... If the page is opened by user typing it in the browser, it loads fine.davisriska commentedon Aug 7, 2023
Could you possibly give some guidance on what you changed in ngsw-worker.js?
JeanMeche commentedon Aug 7, 2023
Looks like there is network error. You should investigate what this error is.
Also, without a repro this is not actionnable on our side.
davisriska commentedon Aug 7, 2023
Got any guidance on how would I go about debugging this? Haven't worked with service workers. Just general direction I have to move in to figure out is fine also.
Also what do you mean by a network error? I have network requests with 404/401 as responses. Would those be the issue?
EDIT: Checked if the 404 was the issue, but that's not the case. So I guess you meant something else.
jcbvm commentedon Aug 7, 2023
An update to this issue, the white page error was caused by a bug on Apple's side, which is fixed by version 16.5:
https://bugs.webkit.org/show_bug.cgi?id=256219
The other error shown in de browser is still present, even on iOS 17 beta. An repro will be difficult because it seems to be a timing issue related to communicating with the browser cache. In some rare cases it seems the cache is not ready yet to communicate with causing the Angular or browser's service worker to run into issues. Debugging is difficult because this happens before the application is loaded.
davisriska commentedon Aug 7, 2023
This is as far as I have gotten now.
legege commentedon Aug 19, 2023
I'm also experiencing this with all iOS 17 public beta to date. @Yang-LiYing Could you explain which error catching you've implemented?
Yang-LiYing commentedon Sep 1, 2023
Here is the modified version of @angular/[email protected] ngsw-worker.js. You can see what changes were made "After" by checking the Git commit history.
https://github.com/Yang-LiYing/modify-the-ngsw-worker-js-example
121 remaining items
luckygro commentedon Dec 8, 2023
I tested it on iOS 17.2 Public Beta and couldn't reproduce the error. Seems like the issue is fixed in the next release - at least there is hope :)
StefanNedelchev commentedon Dec 8, 2023
But is there an official information on the release date? And since this is such a critical bug why don't they backport it to 17.1.X with a patch release?
janniemeyer commentedon Dec 12, 2023
As far as i can tell the issue on Safari's side was fixed with yesterday's 17.2 release.
joaopop5 commentedon Dec 14, 2023
I was facing the same problem today. Updating iOS to v17.2 worked for me. I'm using Angular v14.2.
StefanNedelchev commentedon Dec 20, 2023
I also confirm - the clients using my app reported that the issue is gone after updating to iOS 17.2
add workaround for ios angular/angular#50378
add workaround for ios angular/angular#50378
add workaround for ios angular/angular#50378
add workaround for ios angular/angular#50378
angular-automatic-lock-bot commentedon Jan 20, 2024
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
fix(service-worker): throw a critical error when `handleFetch` fails (a…
fix(service-worker): throw a critical error when handleFetch fails (a…
fix(service-worker): throw a critical error when `handleFetch` fails (a…
fix(service-worker): throw a critical error when handleFetch fails (a…