Sdk 3.x manage authentication error

Couchbase SDK 3.0.2

const couchbase = require('couchbase')
    let cluster
    (async () => {
      try {
        const options = { username: 'Administrator', password: 'bad_password' }
        cluster = new couchbase.Cluster('http://127.0.0.1', options)
        const bucket = cluster.bucket('travel-sample')
        const collection = bucket.defaultCollection()
        const getResult = await collection.get('airport_1254')
        console.dir(getResult.value)
        await cluster.close()
      } catch (err) {
        console.error(err)
        await cluster.close()
      }
    })()

I get a generic “cluster object was closed”. How can I get a more specific bad authentication error?
Thanks

const logFunc = log => log.severity > 3 && console.warn(log.severity, log.message)
const options = { username: 'Administrator', password: '9021h00', logFunc }

With a logFunc, I get this lines of logs:

4 '<127.0.0.1:11210> (CTX=00000000023C3C30,sasl,SASLREQ=0000000002401FD0) Error: 0xce, SASL Step failed (ref: "7667356b-9898-4a54-cd50-05a24aeacee7")'
4 '<NOHOST:NOPORT> (CTX=0000000000000000,) Could not get configuration: LCB_ERR_AUTHENTICATION_FAILURE (206)'
4 'Failed to bootstrap client=00000000023AC050. Error=LCB_ERR_AUTHENTICATION_FAILURE (206), Message=No more bootstrap providers remain'

Hey @dalborgo,

For future reference, you can also simply set the DEBUG=* environment variable, our default logging implementation runs through the popular Node.js library called ‘debug’. In terms of the authentication failure only appearing in logs as opposed to being an obvious error. We made the choice in SDK 3 to try and centralize these errors more as it’s possible that they appear at any time, even after initial connection. A side-effect of this is that many of these kinds of errors show up in logging and the operations you perform timeout as opposed to error’ing immediately.

Cheers, Brett

1 Like

Thank you.
Setting the DEBUG=couchnode environment variable I filter the log I needed.