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
Reachability class prone to indicate a false positive of client's connectivity #13206
Comments
Our customers are experiencing the same issue where DataStore seems to be stuck syncing ('ready' not being emitted) on devices with very poor internet connections. @luisenaguero could you share a code snippet of your workaround? |
Hey, @schutzelaars ! What we ended up doing for now was to have the Reachability class to not only listen the online/offline events but also have it be subscribed to our own BroadcastChannel which receives a message based on a heartbeat we placed in a ServiceWorker that every so often makes a request to an url to verify the connectivity. Reachability class
Service worker
If the client has poor connection, either way this might not be completely accurate. Hope this helps. |
Thanks! In the near future, I'll also implement a connectivity checker. Did you encounter any gotchas when implementing the simplifiedConnectivityChecker function? |
Hello, @luisenaguero and thank you for opening this issue. I'm going to mark this as a feature request at this point after reviewing this with the team internally. The purpose of the exponential backoff is to avoid inundating infrastructure that's attempting to come back online. That could be AppSync or any piece of "network" between the client and AppSync. Regardless of the network, it's a "best practice" to back off to give the "thing that's down" or unavailable room to breath and come back online. That said, exponential backoff should inherently retry a handful of times very quickly. If the network is still connecting, I would expect reconnect within seconds and retry to also succeed within a few seconds. If the network is "down", I'd similarly expect exponential backoff to at least be proportional to the time to recovery. |
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
DataStore
Amplify Version
v5
Amplify Categories
api
Backend
Amplify CLI
Environment information
Describe the bug
Given that the Reachability class relies on
navigator.onLine
(which can indicate a false positive upon being connected to a network with no internet), we've noticed that the "ready" event of DataStore can take sometime to be triggered (as it remains trying to sync the models).At the same time, since it's not aware that there's no connection, upon tryin to update a model, it uses an Exponential Backoff strategy and, when the client is actually connected, it might take some time (until the next try) to perform these updates.
Expected behavior
Based on the previously mentioned issue, we've had to handle on our app a heartbeat to verify the connection, but we've noticed that there's no way to manually trigger a
DataStore.sync
upon our app detecting that the connection is back but instead we need to wait for the next try of DataStore to dispatch those pending requests.It would be nice to have that DataStore sync method exposed or maybe another way to feed the Reachability class (for now, we have it subscribe to a BroadcastChannel to receive a network status' msg).
Reproduction steps
Code Snippet
// Put your code below this line.
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: