Details
Description
With a testing code (below), i got various results, but NEVER the expected one (run in normal or admin mode):
- cluster closed with no reason
- programme did not end and i had to stop node/npm manually
- programme stopped and no reason given
Here is the code:
/*****************************************************************************
|
import & def
|
*****************************************************************************/
|
|
import couchbase from'couchbase' |
import nconf from 'nconf' |
|
|
import {files} from '../util/export.js' |
|
const SFP = function(p){return p.then(d=>[null,d],e=>[e])} |
|
nconf
|
.argv()
|
.file(files.setPathFor(`./configs/${nconf.get('env')||'dev'}.config.json`)) |
.required(['config','config:db','config:logger']) |
|
|
function dbConfig(params){ |
var { |
protocol,
|
user,
|
password,
|
url,
|
port,
|
cluster,
|
} = params
|
|
return { |
url:new URL(`${protocol}://${url}`).toString(), |
opt:{
|
username:user,
|
password,
|
// logFunc:(...a)=>console.log(JSON.stringify(a)) |
}
|
}
|
}
|
|
const db = dbConfig(nconf.get('config:db')) |
var connectOpt = [db.url,db.opt] |
|
const opTIMEOUT = {timeout:10} //s |
|
|
// connect for cluster manager
|
var cluster = await couchbase.connect(...connectOpt) |
var clustermanager = cluster.buckets() |
|
var bucketOpt = { |
// name:'testing',
|
// bucketType:base or ephermeal,
|
ramQuotaMB:100, // |
replicaNumber:0,
|
ConflictResolutionType:"seqno" |
// flushEnabled:false, |
// managementTimeout:1, |
// kvTimeout:1, |
}
|
|
/*****************************************************************************
|
process function
|
*****************************************************************************/
|
|
async function process(bucketSettings){ |
var [err,res] = await SFP(clustermanager.createBucket(bucketSettings)) |
console.log('createBucket 1 - expected:undefined,true - result:',bucketSettings.name,err?.message,res) |
// expected err=null, res = true |
|
var [err,res] = await SFP(clustermanager.createBucket(bucketSettings)) |
console.log('createBucket 2 - expected:error exists,undefined - result:',bucketSettings.name,err?.message,res) |
// expected err=null, res = bucket exists |
|
var bucket = cluster.bucket(bucketSettings.name) |
|
var collectionOpt = { |
name:'collecTest', |
scopeName:'scopeTest', |
maxExpiry:120
|
}
|
|
var manager = bucket.collections() |
var [err,scopeRes] = await SFP(manager.createScope(collectionOpt.scopeName,opTIMEOUT)) |
console.log('createScope 1 - expected:undefined,true - result:', err?.message,scopeRes) |
var [err,scopeRes] = await SFP(manager.createScope(collectionOpt.scopeName,opTIMEOUT)) |
console.log('createScope 2 - expected:error exists,undefined - result:',err?.message,scopeRes) |
|
var scope = bucket.scope(collectionOpt.scopeName) |
|
var [err,collectionRes] = await SFP(manager.createCollection(collectionOpt,opTIMEOUT)) |
console.log('createCollection 1 - expected:undefined,true - result:', err?.message,collectionRes) |
var [err,collectionRes] = await SFP(manager.createCollection(collectionOpt,opTIMEOUT)) |
console.log('createCollection 2 - expected:error exists,undefined - result:',err?.message,collectionRes) |
|
var collection = bucket.collection(collectionOpt.scopeName) |
}
|
|
/*****************************************************************************
|
run
|
*****************************************************************************/
|
|
// BASE
|
var bucketOptBase = { |
...bucketOpt,
|
name:'testingBase', |
bucketType:couchbase.BucketType.Couchbase
|
}
|
console.log('START',bucketOptBase.name) |
await process(bucketOptBase)
|
console.log('DONE',bucketOptBase.name) |
|
|
// EPHEMERAL
|
var bucketOptEphermer = { |
...bucketOpt,
|
name:'testingEphermeral', |
bucketType:couchbase.BucketType.Ephemeral
|
}
|
console.log('START',bucketOptEphermer.name) |
await process(bucketOptEphermer)
|
console.log('DONE',bucketOptEphermer.name) |
here are various results:
- cluster closed
START testingBase
createBucket 1 - expected:undefined,true - result: testingBase undefined true
createBucket 2 - expected:error exists,undefined - result: testingBase bucket exists undefined
createScope 1 - expected:undefined,true - result: cluster object was closed undefined
createScope 2 - expected:error exists,undefined - result: parent cluster object has been closed undefined
createCollection 1 - expected:undefined,true - result: parent cluster object has been closed undefined
createCollection 2 - expected:error exists,undefined - result: parent cluster object has been closed undefined
DONE testingBase
START testingEphermeral
createBucket 1 - expected:undefined,true - result: testingEphermeral parent cluster object has been closed undefined
createBucket 2 - expected:error exists,undefined - result: testingEphermeral parent cluster object has been closed undefined
createScope 1 - expected:undefined,true - result: cluster object was closed undefined
createScope 2 - expected:error exists,undefined - result: parent cluster object has been closed undefined
createCollection 1 - expected:undefined,true - result: parent cluster object has been closed undefined
createCollection 2 - expected:error exists,undefined - result: parent cluster object has been closed undefined
DONE testingEphermeral
- running the code again (buckets are created), had to stop the programme manually
START testingBase
createBucket 1 - expected:undefined,true - result: testingBase bucket exists undefined
createBucket 2 - expected:error exists,undefined - result: testingBase bucket exists undefined
createScope 1 - expected:undefined,true - result: undefined true
createScope 2 - expected:error exists,undefined - result: scope exists undefined
createCollection 1 - expected:undefined,true - result: undefined true
createCollection 2 - expected:error exists,undefined - result: collection exists undefined
DONE testingBase
START testingEphermeral
createBucket 1 - expected:undefined,true - result: testingEphermeral undefined true
createBucket 2 - expected:error exists,undefined - result: testingEphermeral bucket exists undefined
createScope 1 - expected:undefined,true - result: cluster object was closed undefined
createScope 2 - expected:error exists,undefined - result: parent cluster object has been closed undefined
createCollection 1 - expected:undefined,true - result: parent cluster object has been closed undefined
createCollection 2 - expected:error exists,undefined - result: parent cluster object has been closed undefined
DONE testingEphermeral
^C
- buckets not existing, programme stopped with no reason
START testingBase
createBucket 1 - expected:undefined,true - result: testingBase undefined true
createBucket 2 - expected:error exists,undefined - result: testingBase bucket exists undefined
createScope 1 - expected:undefined,true - result: undefined true
createScope 2 - expected:error exists,undefined - result: scope exists undefined
Attachments
Issue Links
- duplicates
-
JSCBC-706 Client does not attempt to reconnect on bucket connect errors
- Resolved