remotestorage.js icon indicating copy to clipboard operation
remotestorage.js copied to clipboard

What to do when navigator goes offline ?

Open clochix opened this issue 11 years ago • 5 comments
trafficstars

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.

clochix avatar Apr 15 '14 20:04 clochix

Yes, that makes total sense. I thought it was already kind of like that.

raucao avatar Apr 15 '14 20:04 raucao

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.

michielbdejong avatar May 13 '14 08:05 michielbdejong

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).

raucao avatar May 13 '14 10:05 raucao

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"

michielbdejong avatar May 13 '14 10:05 michielbdejong

We could also just alias the property and have a nice name in both cases.

raucao avatar May 13 '14 10:05 raucao