Open mlecoq opened 5 years ago
Hi @mlecoq
I am going to label this as a feature request, we've been slowly exposing more control over this kind of stuff (e.g. cvustom storage engines for redux-persist) and exposing a way to customize online detection sounds like a useful addition
@manueliglesias something like this could be achieved by exposing the offlineStateLens
that redux-offline exposes, I think.
I am using AppSync with React Native / Expo to have offline capabilities.
It works fine when I switch off/on internet access on my phone.
Nevertheless, when I switch back on to be connected to a wifi with no internet connection, my application slow down and becomes unusable.
AppSync seems to try to send many times stored mutations and causes this issue. When I look into the code, I see that AppSync is based on redux-offline and retries a factor of 100 ms.
https://github.com/awslabs/aws-mobile-appsync-sdk-js/blob/b933379125e0cb1238020a31f4276b56ae8b233e/packages/aws-appsync/src/link/retry-link.ts#L18
By default Redux offline is less eager. Its default implementation uses the following schedule to retry requets:
After 1 seconds After 5 seconds After 15 seconds After 30 seconds After 1 minute After 3 minutes After 5 minutes After 10 minutes After 30 minutes After 1 hour
We would like to configure network detection. When we look in redux-offline configuration, there is a detectNetwork method that can be used :
https://github.com/redux-offline/redux-offline/blob/develop/docs/api/config.md#detectnetwork
I have seen a pull request for this ( https://github.com/awslabs/aws-mobile-appsync-sdk-js/pull/99 ). But it has not been merged.
After contacting AWS Support, the proposed solution is to use retryDelayOptions and customBackoff from AWS SDK.
What is the proper way to handle this issue ?
Thanks