Understanding Sync states and logging in live replication

394 views
Skip to first unread message

Danielo Rodríguez

unread,
Jun 5, 2015, 5:48:31 PM6/5/15
to pou...@googlegroups.com
Hello everyone,

I'm using pouchdb to provide replication to tiddlywiki. Everything is working nicely, except replication status feedback and logging. Regarding information at a first instance I though that pouchdb just calls its subscribers with statuses of syncing,complete (all up to date) and paused (no connection,we will try later), but seems that it is not so simple. I'm logging all the statuses and seems that the "change" event is the one that provides more information, active is just one-second state when pouch starts to sync again and paused seems to be the natural state. Could someone provide me some guidelines? Should I show a OK with a back-tick to the user when pouch is on pause state? How can I detect offline status? The only thing close to it seems to be error.

And I'm not sure how to manage logging. Most of the times, there is an active cookie on the browser, but I can't know it before hand. Should I try to log into the server BEFORE activating the live sync? Should I do it even before creating the remote database instance?


I'm talking about live sync. Thanks in advance.

Danielo Rodríguez

unread,
Jun 6, 2015, 3:18:34 PM6/6/15
to pou...@googlegroups.com
Any kind of advise is welcome,point to documentation (which I already searched) or even guessings

Dale Harvey

unread,
Jun 7, 2015, 4:18:15 PM6/7/15
to pou...@googlegroups.com
So if you are doing live replication

1. Any login etc that you need to do against the remote CouchDB should be done before you start syncing

2. For the events, the main documentation is @ http://pouchdb.com/api.html#replication

The basic events you should need to show UI are:

 'paused(err)' - you have paused, if there is an error it is because we cannot talk to your couchdb instance (likely offline), if there is no error then it means you have all the change we need and are waiting for more

'active' - After being paused (or when starting), replication is currently happening

'error' - There was a fatal error and replication has stopped and will not restart

Cheers
Dale

On 6 June 2015 at 20:18, Danielo Rodríguez <rdan...@gmail.com> wrote:
Any kind of advise is welcome,point to documentation (which I already searched) or even guessings

--
You received this message because you are subscribed to the Google Groups "PouchDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pouchdb+u...@googlegroups.com.
To post to this group, send email to pou...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pouchdb/ea6a1675-ec4d-462b-b5ec-e2ebeeb94324%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Danielo Rodríguez

unread,
Jun 7, 2015, 6:39:25 PM6/7/15
to pou...@googlegroups.com
Hello Dale,

Thank you very much for your explanation. I did not though about the special case of the pause err. Now I think I can show an OK tick ✅ in case of pause without error. Regarding the error state, will it not retry even if the retry option is set to true? Maybe this error is so catastrophic that it is not possible to retry?

I have readed the documentation, but I find your explanation more cleaner for my case. Thank you very much

Danielo Rodríguez

unread,
Jun 7, 2015, 6:44:11 PM6/7/15
to pou...@googlegroups.com
Regarding logging,

I saw that pouch accepts authentication credentials when creating a remote database, but seems that it only uses basic authentication. Is any possible way to use cookies instead?

My other problem with login is that I don't have a reliable way to know if the user is logged or not. The replication is working with basic authentication even if I do not provide the credentials to pouch. The remote server asks for them and then pouch picks them up from somewhere.

Dale Harvey

unread,
Jun 7, 2015, 6:56:18 PM6/7/15
to pou...@googlegroups.com
Cool I will try to make the documentation clearer. As for the error state this is only used for unrecoverable errors, this should almost never happen with retry: true (I cant quite remember when it can happen)

PouchDB will reuse any cookies you have set on the domain it talks to, so if you login to your remote couch and it sets a cookie, the pouchdb requests will contain that cookie.

--
You received this message because you are subscribed to the Google Groups "PouchDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pouchdb+u...@googlegroups.com.
To post to this group, send email to pou...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages