DataStore would not attempt to re-establish subscriptions when subscription timeout or handshake error occured
See original GitHub issueDescribe the bug
Subscriptions with PubSub in DataStore can be very fragile and would not re-attempt to re-estalish itself when an internet disconnection happen over a short period of time. Network drops are common and therefore DataStore’s subscriptions needs the resilience to recover from such scenario.
After the merge of PR #6366, DataStore would only re-estalish the subscriptions in the case of Connection closed
and Timeout disconnect
. However, if there is a failure when conducting a handshake or when the client didnt receive start_ack
from server, DataStore would not do anything. Do that note that, on React Native, NetInfo is unable to detect a transient network drop has occured. Hence, it will tell DataStore that the client is online throughout despite a network drop.
I have highlighted the failure point in red which DataStore subscriptions does not recover.
In purple, currently the client will only know that the websocket has broken off after 5 minutes when it did not receive KA
from the server. In my opinion, 5 minutes is too long for PubSub to detect Timeout disconnect
has happened. We would lose all the data that happened during this period, it simply doesn’t cut for our project. Perhaps we can lower this down to a minute and half?
To Reproduce Steps to reproduce the behavior:
- iPad > Developer setting > Network Link Conditioner > Enable Bad network.
- Leave the app open for few hours and check back every 1 hour to see whether the subscription remains alive or not.
This can be tricky to reproduce therefore you need to have the patience.
Expected behavior
DataStore subscriptions should recover or at least re-estalish itself when handshake error or subscription timeout has occured.
**I’ve made some changes to force DataStore to re-establish the subscriptions when subscription timeout has occured. However, if we would constantly re-establish the subsciptions on the same websocket over and over within a short period, the client would easily hit Max subscriptions
error. I don’t know what else I can do apart from this.
What is Configured?
Environment
System:
OS: macOS 10.15.5
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 179.66 MB / 8.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.3.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Browsers:
Chrome: 84.0.4147.105
Safari: 13.1.1
npmGlobalPackages:
@aws-amplify/cli: 4.22.0
ios-deploy: 1.10.0
npm: 6.14.4
react-native-cli: 2.0.1
Smartphone (please complete the following information):
- Device: iPad
- OS: iOS 13
- React Native
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:33 (20 by maintainers)
Top GitHub Comments
Hey sorry everyone, I’m closing this issue as it has become cluttered and I could not provide clear reproduction steps despite listing the flaws it has in words.
I have given up on DataStore and I wholeheartledly cannot vouch to use it on production due to the number of criticial bugs it still has and its architecture that I cant reason with.
You should file a new issue if you are still facing the same problem I had in the past.
Just wanted to reach out and see if there is any update on this. Thanks!