Cluster.query throws no error

Hi,

I have the following simple code and if the couchbase container is up, already works fine and I get my docs as expected. Then I wanted to know if any error occurs if I shut down the couchbase container and try to call an N1QL Query via cluster.query(). What happened is, that with the cluster.query() it kills the whole app and didn’t throw any error. I set multiple breakpoints but if the cluster.query() fails its shuts down immediately. Maybe you have an idea what’s going on there.

let couchbase = require(‘couchbase’);
let cluster = new couchbase.Cluster(url, {
username: user,
password: pwd,
});
let bucket = cluster.bucket(‘test’);
let coll = bucket.defaultCollection();

    try {
        let res = await cluster.query(query, {
            scanConsistency: couchbase.QueryScanConsistency.RequestPlus,
            readOnly: true
        });
        return res.rows;
    } catch (err) {
        console.log(err);
    }

Is there any event or check if the cluster is connected? I wanted to check that, to implement a retry function in case the couchbase is down.

Thanks in advance!

Which version of the SDK are you using?

1 Like

We are using the latest Couchbase Node.js Client 3.0.5 (https://www.npmjs.com/package/couchbase)