remotestorage.js
remotestorage.js copied to clipboard
What to do when navigator goes offline ?
When navigator goes offline, sync request fails, emit an error message, and then try again to sync, until it works.
This seems reasonable, but if the error are logged, this may result in lot of log messages.
I got around this issue by calling stopSync() when navigator goes offline, and not logging errors when offline, but I wonder if we shouldn't wait a little bit before trying again to sync on network failure. Wait 5s, then 10s… 60s.
Yes, that makes total sense. I thought it was already kind of like that.
this was fixed in #665, thanks a lot @clochix for working on that! we rebased your PR and merged it a couple of days ago.
The merged PR was for the app being in the background via the Page Visibility API, not for going offline (which is a bit hairy, because navigator.online is not exactly the most reliable Web API).
ah but we're already detecting that, and reducing sync.numThreads from 5 to 1 in that case. It would be a one-liner to also switch to the background sync interval in that case (and maybe rename it because it would then be "background or offline"
We could also just alias the property and have a nice name in both cases.