cloudant / nodejs-cloudant

Cloudant Node.js client library
Apache License 2.0
255 stars 90 forks source link

Callback error ignored in ping() function #177

Closed discretepackets closed 7 years ago

discretepackets commented 7 years ago

I have added comments to this commit https://github.com/cloudant/nodejs-cloudant/commit/6e550bbe204ee77e4a1fa342dbfdda881c9a919a to point out parts where I think the callback errors are ignored.

I discovered this after updating to the latest version and the library fails to error out when the database is unreachable. This issue only happens for the case where the Cloudant library is passed a custom url, i.e.:

var opts = {
    url: 'http://127.0.0.1:5984'
}

var cloudant = Cloudant(opts, function(err) {
    if (err) {
        return console.log("Error connecting to CouchDB", err);
    }

    return console.log("Successfully connected to CouchDB");
});

After the changes in the referenced commit, the code above will always return "Successfully connected to CouchDB". In previous versions, the code will print an error if the host provided in opts is inaccessible or invalid.

glynnbird commented 7 years ago

Thanks for reporting @discretepackets