0
votes

I'm using PouchDB 4.0. To test the credentials to a remote CouchDB server, I use the following code:

testCredentials: function(credentials, callback){
    var remoteDb = new PouchDB('http://X.X.X.X/dbName', {
        auth: {
            username: credentials.username,
            password: credentials.password
        }
    });

    remoteDb.info(function(err, info) {
        if (err) { 
            if(err.status == 401)
                callback("unauthorized");
            else {
                console.log(err); 
                callback("error");
            }
        } else {
            callback("success");
        }
    });
}

When I pass invalid credentials (e.g. existing user but invalid password), I see a 401 error returned inside the CouchDB log file. However, PouchDb always returns the following 500 error:

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

The same problem occurs when using the pouchdb-authentication plugin. This code worked perfectly in previous versions of PouchDB.

1

1 Answers

-1
votes

Can you file a bug with steps to reproduce at the Github issues page? Seems to be a new bug in PouchDB. Also if you could print out the logs from the error (might be an HTTP error, check the "Network" tab), then that would be helpful too.

"Database encountered an unknown error" is a generic error message that PouchDB throws up when it hits an error it doesn't know how to handle, so posting or screenshotting that other error would be very helpful. :)

Also, if you are using pouchdb-authentication, then you typically don't need to add the auth option when creating a new PouchDB; that option is for plain http-based authentication, whereas pouchdb-authentication uses cookie authentication.