PouchDB database encountered unknown error
Asked Answered
M

1

6

I am getting the "Database encountered an unknown error" message while replicating the data from a couchDB Database. It starts replicating, downloads a few documents and then it fails after replicating some documents. I am not able to get the exact issue why this happens.

CustomPouchError {status: 500, name: "unknown_error", message: "Database encountered an unknown error", error: true, result: Object}

Maura answered 27/12, 2015 at 13:58 Comment(4)
What is the actual error returned from the CouchDB server? You can see this either on the client side in the browser dev tools (by looking at the HTTP response body for that request) or on the server side in the CouchDB logs.Modernize
Nothing comes up on this. Not even in the logs.Maura
Are you using PouchDB from a browser, or from node.js? If in a browser, you should be able to see the requests it makes in the developer tools. Also, can you add an .on('error', function (e) { console.error(e, e.result); }) listener to the replication object to get more information about the error?Modernize
One other thing that might help is to add more details about your database to the question: is it a lot of documents? does it have some very big documents/attachments? is it accessed over a particularly unreliable connection?Modernize
G
0

There could be many reasons:

  1. CORS problems, due to they are not enabled on server-side: https://pouchdb.com/getting-started.html#enabling_cors
  2. 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)
  3. 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)

Guenevere answered 3/4, 2018 at 17:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.