I'm currently migrating one of our services from the old NodeJS SDK version (2.6.12) to the most recent one (4.2.7).
For testing I run a local couchbase cluster using docker. The version is Enterprise Edition 7.1.3 build 3479.
When I try to connect to the cluster using our legacy code (and the old SDK version) it works. When I try to connect using the new SDK I get the following error:
[RequestCanceledError: request canceled] {
cause: [Error: request_canceled (2)] { code: 2 },
context: undefined
}
This is the new code (bucket and username are the same), which throws the error in cb.connect(...):
const uri = "couchbase://localhost:8091"
const bucket = "test";
const pw = "password"
const timeoutOperation = 2;
async function run() {
const cluster = await cb.connect(uri, {
"username": bucket,
"password": pw,
"timeouts": {
"kvTimeout": timeoutOperation * 1000
}
});
const openBucket = cluster.bucket(bucket);
const connection = openBucket.defaultCollection();
}
run();
This is our legacy code, which uses the old NodeJS SDK version. It works fine:
async function connectToBucketOld(){
const cluster = new cbOld.Cluster(uri);
const connection: cbOld.Bucket = await new Promise((resolve, reject) => {
let connection;
const cb = err => (err ? reject(err) : resolve(connection));
connection = cluster.openBucket(bucket, pw, cb);
});
connection.operationTimeout = 1000 * timeoutOperation;
return { connection };
}