There could be many reasons:
- CORS problems, due to they are not enabled on server-side: https://pouchdb.com/getting-started.html#enabling_cors
- if the to-be-downloaded docs are too huge, there may be problems with timeout: in this case you can set the timeout on couchDB configuration and on client-side during db replication (https://pouchdb.com/api.html#replication)
- many others :)
But, my definitive solution was using the retry option in replication (https://pouchdb.com/api.html#replication), forcing to retry replications in the case of failure:
PouchDB.replicate(localDB, baseRemoteDB,
{
live: true,
retry: true,
timeout: false
}
)
As result, the replication is paused each two docs (instead of being stopped with unknown error) and it resumes after a few moments, starting from the first new doc. The time-to-retry can be also customised by a backoff function (see the previous doc)
.on('error', function (e) { console.error(e, e.result); })
listener to the replication object to get more information about the error? – Modernize