Skip to content

FetchEvent.respondWith error iOS/iPadOS 16.4+ #50378

Closed

Description

@jcbvm

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:

Scherm­afbeelding 2023-05-20 om 14 08 17

(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

  1. added
    area: service-worker
    on May 22, 2023
  2. added this to the needsTriage milestone on May 22, 2023
  3. AMO-brandon commented on May 24, 2023

    @AMO-brandon

    We have also encountered this issue. We are on angular 13, any ETA on a fix?

  4. AMO-brandon commented on May 30, 2023

    @AMO-brandon

    bump

  5. added
    iOS
    on Jul 5, 2023
  6. Yang-LiYing commented on Aug 3, 2023

    @Yang-LiYing

    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.

    Angular CLI: 14.2.10
    Node: 16.19.0
    Package Manager: npm 8.19.3
    OS: win32 x64
    
    Angular: 14.2.12
    ... animations, common, compiler, compiler-cli, core, forms
    ... language-service, platform-browser, platform-browser-dynamic
    ... router, service-worker
    
    Package                         Version
    ---------------------------------------------------------
    @angular-devkit/architect       0.1402.10
    @angular-devkit/build-angular   14.2.10
    @angular-devkit/core            14.2.10
    @angular-devkit/schematics      14.2.10
    @angular/cdk                    14.2.7
    @angular/cli                    14.2.10
    @schematics/angular             14.2.10
    ng-packagr                      14.2.2
    rxjs                            6.6.7
    typescript                      4.8.4
    

    This is the error we captured during the service worker runtime.

    Cache API operation failed: Internal error
    Unhandled Promise Rejection: NetworkError: A network error occurred
    
  7. davisriska commented on Aug 7, 2023

    @davisriska

    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.

    Node: 16.20.0
    Package Manager: npm 9.6.6
    OS: linux x64
    
    Angular: 15.2.9
    ... animations, cdk, common, compiler, compiler-cli, core, forms
    ... material, material-luxon-adapter, platform-browser
    ... platform-browser-dynamic, router, service-worker
    
    Package                         Version
    ---------------------------------------------------------
    @angular-devkit/architect       0.1502.8
    @angular-devkit/build-angular   15.2.8
    @angular-devkit/core            15.2.8
    @angular-devkit/schematics      15.2.8
    @angular/cli                    15.2.8
    @schematics/angular             15.2.8
    rxjs                            7.8.1
    typescript                      4.8.4```
    
  8. davisriska commented on Aug 7, 2023

    @davisriska

    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.

    Angular CLI: 14.2.10
    Node: 16.19.0
    Package Manager: npm 8.19.3
    OS: win32 x64
    
    Angular: 14.2.12
    ... animations, common, compiler, compiler-cli, core, forms
    ... language-service, platform-browser, platform-browser-dynamic
    ... router, service-worker
    
    Package                         Version
    ---------------------------------------------------------
    @angular-devkit/architect       0.1402.10
    @angular-devkit/build-angular   14.2.10
    @angular-devkit/core            14.2.10
    @angular-devkit/schematics      14.2.10
    @angular/cdk                    14.2.7
    @angular/cli                    14.2.10
    @schematics/angular             14.2.10
    ng-packagr                      14.2.2
    rxjs                            6.6.7
    typescript                      4.8.4
    

    This is the error we captured during the service worker runtime.

    Cache API operation failed: Internal error
    Unhandled Promise Rejection: NetworkError: A network error occurred
    

    Could you possibly give some guidance on what you changed in ngsw-worker.js?

  9. JeanMeche commented on Aug 7, 2023

    @JeanMeche
    Member

    Looks like there is network error. You should investigate what this error is.

    Also, without a repro this is not actionnable on our side.

  10. davisriska commented on Aug 7, 2023

    @davisriska

    Looks like there is network error. You should investigate what this error is.

    Also, without a repro this is not actionnable on our side.

    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.

  11. jcbvm commented on Aug 7, 2023

    @jcbvm
    Author

    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.

  12. davisriska commented on Aug 7, 2023

    @davisriska

    This is as far as I have gotten now.

    image

  13. legege commented on Aug 19, 2023

    @legege

    I'm also experiencing this with all iOS 17 public beta to date. @Yang-LiYing Could you explain which error catching you've implemented?

  14. Yang-LiYing commented on Sep 1, 2023

    @Yang-LiYing

    I'm also experiencing this with all iOS 17 public beta to date. @Yang-LiYing Could you explain which error catching you've implemented?

    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

  15. 121 remaining items

  16. luckygro commented on Dec 8, 2023

    @luckygro

    Looks like there is a fix in IOS 17.2 https://developer.apple.com/documentation/safari-release-notes/safari-17_2-release-notes

    Fixed a cache miss bug in DOMCache that triggered service worker fetch errors. (115740959) (FB13188943)

    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 :)

  17. StefanNedelchev commented on Dec 8, 2023

    @StefanNedelchev

    Looks like there is a fix in IOS 17.2 https://developer.apple.com/documentation/safari-release-notes/safari-17_2-release-notes

    Fixed a cache miss bug in DOMCache that triggered service worker fetch errors. (115740959) (FB13188943)

    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 :)

    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?

  18. janniemeyer commented on Dec 12, 2023

    @janniemeyer

    As far as i can tell the issue on Safari's side was fixed with yesterday's 17.2 release.

  19. joaopop5 commented on Dec 14, 2023

    @joaopop5

    I was facing the same problem today. Updating iOS to v17.2 worked for me. I'm using Angular v14.2.

  20. StefanNedelchev commented on Dec 20, 2023

    @StefanNedelchev

    I also confirm - the clients using my app reported that the issue is gone after updating to iOS 17.2

  21. angular-automatic-lock-bot commented on Jan 20, 2024

    @angular-automatic-lock-bot

    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.

  22. locked and limited conversation to collaborators on Jan 20, 2024
  23. added 2 commits that reference this issue on Jan 23, 2024
    1e3112c
    1fe3016
  24. added 2 commits that reference this issue on Jan 26, 2024
    dcaad16
    cc7973f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1area: service-workerbugiOS

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions