[SOLVED] [OSX] Connection issue

Hi, i am using couchbase CE edition on OSX (Mojave 10.14.5), the server is running as exepected, i have the latest version of the server (Community Edition 6.6.0 build 7909) and of nodejs (v12.18.4)

Here is my code

const couchbase = require("couchbase");

let db = new couchbase.Cluster("couchbase://127.0.0.1:8091", {
    username: "<myadminuser>",
    password: "<mypassword>",
});

let bucket = db.bucket("Ludopedia");

var coll = bucket.defaultCollection();

coll.upsert('testdoc', { name: 'Frank' }, (err, res) => {

    if (err){
        console.log(err)
    }

    coll.get('testdoc', (err, res) => {
        if (err){
            console.log(err)
        }
        console.log(res.value);
    })
 })

Here is the error stack

Error: cluster object was closed
at Connection.close (/Volumes/Transcend/Developement/2020/ludopedia/node_modules/couchbase/lib/connection.js:256:25)
at /Volumes/Transcend/Developement/2020/ludopedia/node_modules/couchbase/lib/cluster.js:555:14
(node:20403) UnhandledPromiseRejectionWarning: Error: parent cluster object has been closed
at Connection._maybeBFwd (/Volumes/Transcend/Developement/2020/ludopedia/node_modules/couchbase/lib/connection.js:226:13)
at Connection.get (/Volumes/Transcend/Developement/2020/ludopedia/node_modules/couchbase/lib/connection.js:261:10)
at /Volumes/Transcend/Developement/2020/ludopedia/node_modules/couchbase/lib/collection.js:228:18
at Function.wrap (/Volumes/Transcend/Developement/2020/ludopedia/node_modules/couchbase/lib/promisehelper.js:25:7)
at Collection.get (/Volumes/Transcend/Developement/2020/ludopedia/node_modules/couchbase/lib/collection.js:227:26)
at /Volumes/Transcend/Developement/2020/ludopedia/couch.js:18:10
at /Volumes/Transcend/Developement/2020/ludopedia/node_modules/couchbase/lib/collection.js:574:20
at Array.<anonymous> (/Volumes/Transcend/Developement/2020/ludopedia/node_modules/couchbase/lib/connection.js:243:25)
at Connection._flushPendBOps (/Volumes/Transcend/Developement/2020/ludopedia/node_modules/couchbase/lib/connection.js:194:24)
at Connection.close (/Volumes/Transcend/Developement/2020/ludopedia/node_modules/couchbase/lib/connection.js:256:10)
(node:20403) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:20403) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

It seems that it’s aknow issue but i don’t found anything to resolve it.

Thanks for the help

I found the solution, the couchbase sdk (or lib, idk) has an issue with error handling. It seems that a connection error do not raise any error. And even if you can’t connect to your server due to an error, the script continue to run and understand a disconect cluster due to error as a closed cluster.

The expected behavior will be :

Error : Unable to connect to the cluster (index.js line 3) (code XXXX, <an error description>)

Or at least

Error : Unable to open the bucket (index.js line 8) (code XXXX , the cluster is not connected)

Maybe it’s a mistake but i think that to add a document we need a connection :slight_smile:

Hi,

Can you look at my problem? Is it the same with you?