I'm trying to fix a problem with the Cloudantplus node where it errors and stops NR if it can't connect to the Cloudant database (incorrect URL or credentials). In the node logic I have:
node.on("input", (msg, send, done) => {
node.debug("Connecting...");
base
.connecWithRetry(node, node.cloudantConfig, 1)
.then((service) => {node.debug("Connected..."); handleMessage(service, node, msg, send, done)})
.catch((err) => {node.debug("Error connecting..."); done(err)})
})
base.connecWithRetry returns a promise but if there is an error in the connection then it never seems to get to the catch clause, it just stops NR. Baffled! It works just fine if it can connect to Cloudant.
The code for connecWithRetry is here: node-red-contrib-cloudantplus/cloudantbase.js at master · hammoaj/node-red-contrib-cloudantplus · GitHub
I'm probably missing something really stupid, but I can't see it. Can't work out why the error isn't being trapped.
Thanks