apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.38k stars 2.66k forks source link

React Native (iOS network error 403) #10980

Closed nazrincode closed 1 year ago

nazrincode commented 1 year ago

Issue Description

Hi, I got this weird issue using this library in my React Native project.

Link to Reproduction

df

Reproduction Steps

These are the flows for both platform iOS and Android:

  1. Success Fetch > Kill app from background > Open app again > And the results are different for both platform which is:

Android : Success Fetch iOS : Keep getting Network Error with status code 403.

phryneas commented 1 year ago

Are you using any kind of persistance?

nazrincode commented 1 year ago

What do you mean by persistance?

phryneas commented 1 year ago

Did you set up something like apollo-cache-persist?

If you did not, restarting your app will always completely clear your cache. In that case you are probably not completely killing your app on iOS - have you tried rebooting your phone?

nazrincode commented 1 year ago

No I'm not using that.

By the way this is my option:

defaultOptions: { watchQuery: { fetchPolicy: 'no-cache', errorPolicy: 'ignore', }, query: { fetchPolicy: 'no-cache', errorPolicy: 'all', }, }

phryneas commented 1 year ago

Oh, wait, I reread that - so this is not an issue with an error persisting over an app restart, but you getting a 403 error?

A 403 is sent by your server to your client - can you take a look at your server logs?

nazrincode commented 1 year ago

I can confirm that is nothing wrong on my server side. Keep getting networkError 403 code. This is really weird because:

For Android : Response 200. For iOS : Response 403.

phryneas commented 1 year ago

403 is a code sent by your server. That usually cannot change on the way to the client, and the client does also not pull that out of thin air.

The 403 might be sent by the server for good reasons, because it is getting a different request from your Android clients vs. your iOS clients, but you would still see in the server logs that the server sent a 403, and why that 403 was sent.

The only alternative is that you have a load balancer or something that changes your status code to a 403, but that is highly unprobably, usually a load balancer would only change the status to a 5xx error code.

bignimbus commented 1 year ago

Hi @nazrincode 👋🏻 sorry you're dealing with issue, sounds frustrating. Unfortunately I don't think there's anything we can offer besides some general advice. Let us know if there's a way for us to reproduce this scenario and I'm sure we'd be able to figure it out. I'll echo Lenz's comments above RE: inspecting the server response, it's likely the source of this problem 🙏🏻

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. For general questions, we recommend using StackOverflow or our discord server.