Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrying mutations on network failure #52

Open
Felix-N opened this issue Aug 8, 2020 · 9 comments
Open

Retrying mutations on network failure #52

Felix-N opened this issue Aug 8, 2020 · 9 comments

Comments

@Felix-N
Copy link

Felix-N commented Aug 8, 2020

Hi Morries,

im currently testing the replay of mutations in case of network failure.

Pure offline/online mode works fine, however as soon as a network query fails that one is not replayed again.
The local store reflects the change, but it won't be communicated to the server.

Am I doing something wrong here, or is this intentional? I'm kinda looking for a retry strategy, the assumption is that users may have a flaky internet connection and requests my fail due to that but should be replayed later on.

@Felix-N
Copy link
Author

Felix-N commented Aug 9, 2020

I found the parts about onDiscard, which resolves part the part of the issue where offline request would be discarded if they failed once online.

However I've still the issue that a request which is being made (while online) fails due to connectivity issues, is not retried.

Should this be handled by the library (in particular TypeError: Failed to fetch)?

@morrys
Copy link
Owner

morrys commented Aug 10, 2020

At the moment I have no retry logic in the library to leave the management at the network level
(eg. react-relay-network-modern)

@morrys
Copy link
Owner

morrys commented Aug 10, 2020

Or in the finish method you can schedule another processing with the process method of the offline store.

@Felix-N
Copy link
Author

Felix-N commented Aug 10, 2020

whats from a user perspective (mine ;)) a bit odd is that a failed network request with a failed to fetch is behaving different than being offline.

as well that if the request was scheduled offline and onDiscard returns false, it is going to be retried even if the network requests fails.

i haven't figured yet out how to handle it well, in particular as the order is important of mutations on the same node.

@morrys
Copy link
Owner

morrys commented Aug 10, 2020

i haven't figured yet out how to handle it well, in particular as the order is important of mutations on the same node.

this is one of the reasons why I have not put retry logic inside the library but I have given the possibility to configure / customize each step of the offline workflow.

@Felix-N
Copy link
Author

Felix-N commented Aug 10, 2020

but isn't the logic kind of implemented if the mutation is done while being 'offline'?

from my perspective i'd love to have one path all mutations or queries take, independent of my current network or connectivity state.

@morrys
Copy link
Owner

morrys commented Aug 11, 2020

What you are asking for is NetInfo's isInternetReachable offline workflow management, which is currently not implemented.

is it right?

@Felix-N
Copy link
Author

Felix-N commented Aug 11, 2020

honestly i do not know netinfo, so hard to say ...

@morrys
Copy link
Owner

morrys commented Aug 12, 2020

At the moment the application is considered offline when the APIs made available in the WEB / react-native consider it as such (If there is an active network connection)

While isInternetReachable defines whether the Internet is reachable with the currently active network connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants