apollo-client icon indicating copy to clipboard operation
apollo-client copied to clipboard

Uncaught TypeError: Failed to fetch simulated offline in Google Chrome.

Open LiamKarlMitchell opened this issue 2 years ago • 5 comments

Intended outcome:

When making a query or polling query and the network has an outage/offline/disconnected. NetworkError is caught, retry-link retries. Polling queries would retry.

Actual outcome:

Uncaught TypeError: Failed to fetch.

Uncaught TypeError: Failed to fetch
    at eval (createHttpLink.js?53eb:96:1)
    at new Subscription (module.js?c1e0:190:1)
    at Observable.subscribe (module.js?c1e0:264:1)
    at subscribeObservable.subscribe (pusher-link.ts?1f2c:32:1)
    at eval (index.js?9187:11:1)
    at new Subscription (module.js?c1e0:190:1)
    at Observable.subscribe (module.js?c1e0:264:1)
    at RetryableOperation.try (retryLink.js?d616:103:1)
    at RetryableOperation.start (retryLink.js?d616:91:1)
    at RetryLink.request (retryLink.js?d616:134:1)

When network connection comes back. No retry attempts are made, and no polling queries are retried everything just stops.

How to reproduce the issue:

Have a retry-link.

Make a query or polling query during a network outage. Can simulate network outage in Chrome Network tab under the throttling drop down. Restore network connection and see that nothing is retried.

Versions

  System:
    OS: Windows 10 10.0.19044
  Binaries:
    Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.3.0 - ~\AppData\Roaming\npm\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (103.0.1264.37)
  npmPackages:
    @apollo/client: ^3.6.9 => 3.6.9
    vue-apollo: ^3.1.0 => 3.1.0

Suspect this is related to https://github.com/apollographql/apollo-client/issues/9870

LiamKarlMitchell avatar Jul 01 '22 09:07 LiamKarlMitchell

@LiamKarlMitchell Thanks for reporting this, it certainly might be related to #9870, so let's see what @MrDoomBringer thinks, as he was working on that issue.

jpvajda avatar Jul 07 '22 23:07 jpvajda

To be fair, I do have Vue Apollo. But this error is coming from apollo client createHttpLink.js, fetch errors seem like they are unhandled so it never makes the ApolloError for me to catch and handle in retry-link or an error-link.

LiamKarlMitchell avatar Jul 08 '22 00:07 LiamKarlMitchell

Is there a way I can have package.json switch over to using the git repo I clone from this project? Then I could muck with the code possibly see where issue is?

LiamKarlMitchell avatar Jul 08 '22 09:07 LiamKarlMitchell

@LiamKarlMitchell Hi! Thanks a ton for opening this issue. I'd need to take a bit of a deeper dive before I can confirm it's related to #9870, as for the most part that issue relates to error reporting, rather than re-polling/fetching errors.

Is there a way I can have package.json switch over to using the git repo I clone from this project?

Yep! After cloning and building this repo, cd to /dist and run npm pack which will create a file named apollo-client-3.xx.tgz in the apollo-client/dist directory

Then in your app, run npm i ~/path/to/folder/apollo-client/dist/apollo-client-3.xx.tgz to install the newly built/modified client. You should see the package.json change to look something like this: image

MrDoomBringer avatar Jul 08 '22 14:07 MrDoomBringer

Still a concern, but I have not had the time to investigate it further yet.

LiamKarlMitchell avatar Aug 06 '22 06:08 LiamKarlMitchell