Handling the Unhandled Promise Rejection Warning if no connection can be made

UnhandledPromiseRejectionWarning: Error: LCB_ERR_NETWORK (1048): Generic network failure

Is there a way to handle this error that I get if a connection to Couchbase cannot be made? Say the password is wrong, or the Couchbase server is down, when the Node.js app starts up, I see these types of warnings. It would be really great to be able to catch those errors and display a more user friendly message. But everything that I try to do to catch this unhandled rejection warning fails to do so.

The connection is started in a promise (new Cluster), but I can’t figure out how to determine if the connection fails in order to call reject in that promise. The promise always resolves, but never rejects. Then, after the app has started I see the UnhandledPromiseRejectionWarning. This is with Couchbase package 3.0.0.

Hey @justinbkay,

This is actually a solved bug which will be fixed in the next release of the SDK. That was due to be released on Tuesday but due to some other issues which we discovered during testing, this has been delayed for a short period of time. We are planning to get the release out as soon as possible.

Cheers, Brett

1 Like

Hi Brett,

Is there a way to test the connection without sending a query? I’d like to know when starting my server if it cannot communicate with Couchbase. I’d like to do the new Cluster command and receive some feedback that it is working. I’ve tried calling diagnostics, but that doesn’t seem to work. Any insight?