I am trying to execute View queries and N1QL queries using the couchbase 2.2.2 Node SDK. I can successfully run the queries most of the time using something like:
const couchbase = require('couchbase');
const cluster = new couchbase.Cluster(`couchbase://<host_here>?detailed_errcodes=1`);
const bucket = cluster.openBucket(CB_BUCKET, '');
const N1qlQuery = couchbase.N1qlQuery;
const query = N1qlQuery.fromString(statement).consistency(N1qlQuery.Consistency.REQUEST_PLUS);
bucket.query(query, function(err, rows, meta) {
.....
but for some reason in CI, when running it the exact same way it does not work and I get the error:
CouchbaseError: Invalid input/arguments
at Bucket._viewReq (/builds/gcosta/election-service/node_modules/couchbase/lib/bucket.js:472:12)
at Bucket._invoke (/builds/gcosta/election-service/node_modules/couchbase/lib/bucket.js:1042:8)
at Bucket._maybeInvoke (/builds/gcosta/election-service/node_modules/couchbase/lib/bucket.js:1061:10)
at Bucket._view (/builds/gcosta/election-service/node_modules/couchbase/lib/bucket.js:539:8)
at Bucket.query (/builds/gcosta/election-service/node_modules/couchbase/lib/bucket.js:942:17)
......
I set the environment variable LCB_LOGLEVEL=5 to see extra output but it is too cryptic for me to understand:
0ms [I0] {3260} [INFO] (instance - L:351) Version=2.6.2, Changeset=788e1eeda075eddd8204ecc3fc5028add74e8074
0ms [I0] {3260} [INFO] (instance - L:352) Effective connection string: couchbase://gcosta__couchtest/main?detailed_errcodes=1&client_string=couchnode%2F2.2.2. Bucket=main
0ms [I0] {3260} [DEBUG] (instance - L:223) Applying initial cntl detailed_errcodes=1
0ms [I0] {3260} [DEBUG] (instance - L:223) Applying initial cntl client_string=couchnode/2.2.2
0ms [I0] {3260} [DEBUG] (instance - L:66) Adding host gcosta__couchtest:8091 to initial HTTP bootstrap list
0ms [I0] {3260} [DEBUG] (instance - L:66) Adding host gcosta__couchtest:11210 to initial CCCP bootstrap list
582ms [I0] {3260} [DEBUG] (confmon - L:89) Preparing providers (this may be called multiple times)
582ms [I0] {3260} [DEBUG] (confmon - L:99) Provider FILE is DISABLED
582ms [I0] {3260} [DEBUG] (confmon - L:96) Provider CCCP is ENABLED
582ms [I0] {3260} [DEBUG] (confmon - L:96) Provider HTTP is ENABLED
582ms [I0] {3260} [DEBUG] (confmon - L:99) Provider MCRAW is DISABLED
582ms [I0] {3260} [TRACE] (confmon - L:292) Start refresh requested
Ballots Test
585ms [I0] {3260} [TRACE] (confmon - L:271) Current provider is CCCP
585ms [I0] {3260} [INFO] (cccp - L:118) Requesting connection to node gcosta__couchtest:11210 for CCCP configuration
585ms [I0] {3260} [DEBUG] (lcbio_mgr - L:416) <gcosta__couchtest:11210> (HE=0x274af90) Creating new connection because none are available in the pool
585ms [I0] {3260} [DEBUG] (lcbio_mgr - L:321) <gcosta__couchtest:11210> (HE=0x274af90) Starting connection on I=0x2640680
585ms [I0] {3260} [INFO] (connection - L:450) <gcosta__couchtest:11210> (SOCK=0x274ae10) Starting. Timeout=2000000us
586ms [I0] {3260} [TRACE] (connection - L:344) <gcosta__couchtest:11210> (SOCK=0x274ae10) Received completion handler. Status=0. errno=0
586ms [I0] {3260} [INFO] (connection - L:116) <gcosta__couchtest:11210> (SOCK=0x274ae10) Connected
586ms [I0] {3260} [DEBUG] (connection - L:123) <gcosta__couchtest:11210> (SOCK=0x274ae10) Successfuly set TCP_NODELAY
586ms [I0] {3260} [DEBUG] (lcbio_mgr - L:271) <gcosta__couchtest:11210> (HE=0x274af90) Received result for I=0x2640680,C=0x274ae10; E=0x0
586ms [I0] {3260} [DEBUG] (lcbio_mgr - L:223) <gcosta__couchtest:11210> (HE=0x274af90) Assigning R=0x2696880 SOCKET=0x274ae10
586ms [I0] {3260} [DEBUG] (ioctx - L:101) <gcosta__couchtest:11210> (CTX=0x275d650,unknown) Pairing with SOCK=0x274ae10
622ms [I0] {3260} [DEBUG] (negotiation - L:368) <gcosta__couchtest:11210> (SASLREQ=0x275d390) Found feature 0x3 (TCP NODELAY)
622ms [I0] {3260} [DEBUG] (ioctx - L:151) <gcosta__couchtest:11210> (CTX=0x275d650,sasl) Destroying. PND=0,ENT=1,SORC=1
622ms [I0] {3260} [DEBUG] (ioctx - L:101) <gcosta__couchtest:11210> (CTX=0x2721470,unknown) Pairing with SOCK=0x274ae10
625ms [I0] {3260} [DEBUG] (ioctx - L:151) <gcosta__couchtest:11210> (CTX=0x2721470,bc_cccp) Destroying. PND=0,ENT=1,SORC=1
626ms [I0] {3260} [INFO] (lcbio_mgr - L:491) <gcosta__couchtest:11210> (HE=0x274af90) Placing socket back into the pool. I=0x2640680,C=0x274ae10
627ms [I0] {3260} [INFO] (confmon - L:174) Setting new configuration. Received via CCCP
627ms [I0] {3260} [DEBUG] (bootstrap - L:55) Instance configured!
627ms [I0] {3260} [DEBUG] (confmon - L:89) Preparing providers (this may be called multiple times)
628ms [I0] {3260} [DEBUG] (confmon - L:99) Provider FILE is DISABLED
628ms [I0] {3260} [DEBUG] (confmon - L:96) Provider CCCP is ENABLED
628ms [I0] {3260} [DEBUG] (confmon - L:99) Provider HTTP is DISABLED
628ms [I0] {3260} [DEBUG] (confmon - L:99) Provider MCRAW is DISABLED
PUT /ballots
747ms [I0] {3260} [INFO] (lcbio_mgr - L:407) <gcosta__couchtest:11210> (HE=0x274af90) Found ready connection in pool. Reusing socket and not creating new connection
747ms [I0] {3260} [DEBUG] (lcbio_mgr - L:223) <gcosta__couchtest:11210> (HE=0x274af90) Assigning R=0x271bc30 SOCKET=0x274ae10
748ms [I0] {3260} [DEBUG] (ioctx - L:101) <gcosta__couchtest:11210> (CTX=0x270a5f0,unknown) Pairing with SOCK=0x274ae10
748ms [I0] {3260} [DEBUG] (server - L:552) <gcosta__couchtest:11210> (SRV=0x271e2d0,IX=0) Setting initial timeout=2498ms
3245ms [I0] {3260} [DEBUG] (server - L:476) <gcosta__couchtest:11210> (SRV=0x271e2d0,IX=0) Scheduling next timeout for 2499 ms
5744ms [I0] {3260} [DEBUG] (server - L:476) <gcosta__couchtest:11210> (SRV=0x271e2d0,IX=0) Scheduling next timeout for 2499 ms
8244ms [I0] {3260} [DEBUG] (server - L:476) <gcosta__couchtest:11210> (SRV=0x271e2d0,IX=0) Scheduling next timeout for 2500 ms
10745ms [I0] {3260} [DEBUG] (server - L:476) <gcosta__couchtest:11210> (SRV=0x271e2d0,IX=0) Scheduling next timeout for 2500 ms
What’s weird is if I use the REST API for N1QL queries for example, they work fine. It must be something with the sdk. Does anyone have any idea what is going on?