Uploaded image for project: 'Couchbase node.js Client Library'
  1. Couchbase node.js Client Library
  2. JSCBC-671

get takes just under 2x timeout to report "collection not found"

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.0.0
    • 3.0.6
    • lcb, library
    • None
    • 1

    Description

      When a non-existent collection is specified. get() (and other) operations do not immediately return with "collection not found".  timeout is set to 3000 ms.  Get completes in 5959 ms with error (slightly less than 2x timeout) .  Subsequent get() calls with 5000ms timeout complete in around 9658 ms (output not shown, run kv-operations.js and hit localhost:3000/getwithoptions

      Also - I suspect the "UnhandledPromiseRejectionWarning" needs to be addressed based on "promise rejections that are not handled will terminate the Node.js process"

      % node kv2.js

      get: 5959

      ===========

      CollectionNotFoundError: collection not found

          at _getWrappedErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:835:14)

          at Object.wrapLcbErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:1008:20)

          at /Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/collection.js:218:24 {

        cause: LibcouchbaseError

      { code: 211 }

      ,

        context: KeyValueErrorContext {

          status_code: 4,

          opaque: 0,

          cas: CbCas

      { '0': <Buffer 00 00 00 00 00 00 00 00> }

      ,

          key: 'airport_77',

          bucket: 'travel-sample',

          collection: '',

          scope: '',

          context: '',

          ref: ''

        }

      }

      =========== get failed with 211

      ===========

      (node:4228) UnhandledPromiseRejectionWarning: Error: collection not found

          at _getWrappedErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:835:14)

          at Object.wrapLcbErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:1008:20)

          at /Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/collection.js:218:24

      (node:4228) 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(). (rejection id: 1)

      (node:4228) [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.

      ^C

      michaelreiche@hqml0612s-mbp examples %

       

      Attachments

        1. kv2.js
          1 kB
        2. kv-operations.js
          12 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            michael.reiche Michael Reiche created issue -
            michael.reiche Michael Reiche made changes -
            Field Original Value New Value
            Attachment kv2.js [ 82124 ]
            michael.reiche Michael Reiche made changes -
            Attachment kv-operations.js [ 82125 ]
            michael.reiche Michael Reiche made changes -
            Assignee Michael Nitschinger [ daschl ] Michael Reiche [ JIRAUSER24711 ]
            michael.reiche Michael Reiche made changes -
            Component/s library [ 10250 ]
            Component/s Core [ 10140 ]
            Key JCBC-1583 JSCBC-671
            Affects Version/s 3.0.0 [ 16607 ]
            Affects Version/s 3.0.0 [ 15514 ]
            Project Couchbase Java Client [ 10080 ] Couchbase node.js Client Library [ 10110 ]
            michael.reiche Michael Reiche made changes -
            Assignee Michael Reiche [ JIRAUSER24711 ] Brett Lawson [ brett19 ]
            michael.reiche Michael Reiche made changes -
            Description timeout is set to 3000 ms.  Get completes in 5959 ms with error (slightly less than 2x timeout)
            Subsequent get() calls with 5000ms timeout complete in around 9658 ms (output not shown, run kv-operations.js and hit localhost:3000/getwithoptions

            Also - I suspect the "UnhandledPromiseRejectionWarning" needs to be addressed based on "promise rejections that are not handled will terminate the Node.js process"

             

            % node kv2.js

             

            get: 5959

            ===========

            CollectionNotFoundError: collection not found

                at _getWrappedErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:835:14)

                at Object.wrapLcbErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:1008:20)

                at /Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/collection.js:218:24 {

              cause: LibcouchbaseError { code: 211 },

              context: KeyValueErrorContext {

                status_code: 4,

                opaque: 0,

                cas: CbCas { '0': <Buffer 00 00 00 00 00 00 00 00> },

                key: 'airport_77',

                bucket: 'travel-sample',

                collection: '',

                scope: '',

                context: '',

                ref: ''

              }

            }

            =========== get failed with 211

            ===========

            (node:4228) UnhandledPromiseRejectionWarning: Error: collection not found

                at _getWrappedErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:835:14)

                at Object.wrapLcbErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:1008:20)

                at /Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/collection.js:218:24

            (node:4228) 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(). (rejection id: 1)

            (node:4228) [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.

            ^C

            michaelreiche@hqml0612s-mbp examples %

             
            When a non-existent collection is specified. get() (and other) operations do not immediately return with "collection not found".  timeout is set to 3000 ms.  Get completes in 5959 ms with error (slightly less than 2x timeout) .  Subsequent get() calls with 5000ms timeout complete in around 9658 ms (output not shown, run kv-operations.js and hit localhost:3000/getwithoptions

            Also - I suspect the "UnhandledPromiseRejectionWarning" needs to be addressed based on "promise rejections that are not handled will terminate the Node.js process"

             

            % node kv2.js

             

            get: 5959

            ===========

            CollectionNotFoundError: collection not found

                at _getWrappedErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:835:14)

                at Object.wrapLcbErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:1008:20)

                at /Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/collection.js:218:24 {

              cause: LibcouchbaseError

            { code: 211 }

            ,

              context: KeyValueErrorContext {

                status_code: 4,

                opaque: 0,

                cas: CbCas

            { '0': <Buffer 00 00 00 00 00 00 00 00> }

            ,

                key: 'airport_77',

                bucket: 'travel-sample',

                collection: '',

                scope: '',

                context: '',

                ref: ''

              }

            }

            =========== get failed with 211

            ===========

            (node:4228) UnhandledPromiseRejectionWarning: Error: collection not found

                at _getWrappedErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:835:14)

                at Object.wrapLcbErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:1008:20)

                at /Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/collection.js:218:24

            (node:4228) 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(). (rejection id: 1)

            (node:4228) [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.

            ^C

            michaelreiche@hqml0612s-mbp examples %

             
            michael.reiche Michael Reiche made changes -
            Description When a non-existent collection is specified. get() (and other) operations do not immediately return with "collection not found".  timeout is set to 3000 ms.  Get completes in 5959 ms with error (slightly less than 2x timeout) .  Subsequent get() calls with 5000ms timeout complete in around 9658 ms (output not shown, run kv-operations.js and hit localhost:3000/getwithoptions

            Also - I suspect the "UnhandledPromiseRejectionWarning" needs to be addressed based on "promise rejections that are not handled will terminate the Node.js process"

             

            % node kv2.js

             

            get: 5959

            ===========

            CollectionNotFoundError: collection not found

                at _getWrappedErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:835:14)

                at Object.wrapLcbErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:1008:20)

                at /Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/collection.js:218:24 {

              cause: LibcouchbaseError

            { code: 211 }

            ,

              context: KeyValueErrorContext {

                status_code: 4,

                opaque: 0,

                cas: CbCas

            { '0': <Buffer 00 00 00 00 00 00 00 00> }

            ,

                key: 'airport_77',

                bucket: 'travel-sample',

                collection: '',

                scope: '',

                context: '',

                ref: ''

              }

            }

            =========== get failed with 211

            ===========

            (node:4228) UnhandledPromiseRejectionWarning: Error: collection not found

                at _getWrappedErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:835:14)

                at Object.wrapLcbErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:1008:20)

                at /Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/collection.js:218:24

            (node:4228) 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(). (rejection id: 1)

            (node:4228) [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.

            ^C

            michaelreiche@hqml0612s-mbp examples %

             
            When a non-existent collection is specified. get() (and other) operations do not immediately return with "collection not found".  timeout is set to 3000 ms.  Get completes in 5959 ms with error (slightly less than 2x timeout) .  Subsequent get() calls with 5000ms timeout complete in around 9658 ms (output not shown, run kv-operations.js and hit localhost:3000/getwithoptions

            Also - I suspect the "UnhandledPromiseRejectionWarning" needs to be addressed based on "promise rejections that are not handled will terminate the Node.js process"

            % node kv2.js

            get: 5959

            ===========

            CollectionNotFoundError: collection not found

                at _getWrappedErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:835:14)

                at Object.wrapLcbErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:1008:20)

                at /Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/collection.js:218:24 {

              cause: LibcouchbaseError

            { code: 211 }

            ,

              context: KeyValueErrorContext {

                status_code: 4,

                opaque: 0,

                cas: CbCas

            { '0': <Buffer 00 00 00 00 00 00 00 00> }

            ,

                key: 'airport_77',

                bucket: 'travel-sample',

                collection: '',

                scope: '',

                context: '',

                ref: ''

              }

            }

            =========== get failed with 211

            ===========

            (node:4228) UnhandledPromiseRejectionWarning: Error: collection not found

                at _getWrappedErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:835:14)

                at Object.wrapLcbErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:1008:20)

                at /Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/collection.js:218:24

            (node:4228) 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(). (rejection id: 1)

            (node:4228) [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.

            ^C

            michaelreiche@hqml0612s-mbp examples %

             

            sometimes only "timeout" is reported, and not the "collection not found".

             

            node kv-operations.js

            collection.constructor  bogus-collection

            get  timeout: 3000

            get  scope

            get  name bogus-collection

            get  key airport_77

            get: 10604

            ===========

            TimeoutError: timeout

                at _getWrappedErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:815:14)

                at Object.wrapLcbErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:1008:20)

                at /Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/collection.js:218:24 {

              cause: LibcouchbaseError

            { code: 201 }

            ,

              context: KeyValueErrorContext {

                status_code: 136,

                opaque: 0,

                cas: CbCas

            { '0': <Buffer 00 00 00 00 00 00 00 00> }

            ,

                key: 'airport_77',

                bucket: 'travel-sample',

                collection: '',

                scope: '',

                context: '',

                ref: ''

              }

            }

            =========== get failed with 201

            ===========

            michael.reiche Michael Reiche added a comment - sometimes only "timeout" is reported, and not the "collection not found".   node kv-operations.js collection.constructor  bogus-collection get  timeout: 3000 get  scope get  name bogus-collection get  key airport_77 get: 10604 =========== TimeoutError: timeout     at _getWrappedErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:815:14)     at Object.wrapLcbErr (/Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/errors.js:1008:20)     at /Users/michaelreiche/git/docs-sdk-nodejs/modules/howtos/examples/node_modules/couchbase/lib/collection.js:218:24 {   cause: LibcouchbaseError { code: 201 } ,   context: KeyValueErrorContext {     status_code: 136,     opaque: 0,     cas: CbCas { '0': <Buffer 00 00 00 00 00 00 00 00> } ,     key: 'airport_77',     bucket: 'travel-sample',     collection: '',     scope: '',     context: '',     ref: ''   } } =========== get failed with 201 ===========

            I'm not familiar with nodejs/promise/reject processing, but to eliminate the UnhandledPromiseRejection, I believe it is sufficient to add a catch() to promisehelper.wrap - similar to asyncWrap.  callback has already been called with the err object by then.

            static async wrap(fn, callback) {
            return new Promise((resolve, reject) => {
            fn((err, res) => {
            if (err)

            { reject(err); }

            else

            { resolve(res); }

            if (callback)

            {   callback(err, res); }

            });
            }).catch((err)=>

            { console.log("CATCH : "+err); /* callback has already been called above */); }

            The callback can capture the exception, and it can be rethrown if the caller needs :

             

            async function getwithoptionsHandler(request, h) {
            var theErr;
            try {
            const result = await collection.get(docKey,

            { timeout: 5000, // 5 seconds }

            , (err, res) =>

            { if(err)  theErr = err; // to rethrow in caller if(res) console.log(res.value); }

            );

            if(theErr) // rethrow
            throw theErr;

            return h.response(result.value);
            } catch (e)

            { console.log(e); return h.response(e.toString()); }

            }

            michael.reiche Michael Reiche added a comment - I'm not familiar with nodejs/promise/reject processing, but to eliminate the UnhandledPromiseRejection, I believe it is sufficient to add a catch() to promisehelper.wrap - similar to asyncWrap.  callback has already been called with the err object by then. static async wrap(fn, callback) { return new Promise((resolve, reject) => { fn((err, res) => { if (err) { reject(err); } else { resolve(res); } if (callback) {   callback(err, res); } }); }).catch((err)=> { console.log("CATCH : "+err); /* callback has already been called above */); } The callback can capture the exception, and it can be rethrown if the caller needs :   async function getwithoptionsHandler(request, h) { var theErr; try { const result = await collection.get(docKey, { timeout: 5000, // 5 seconds } , (err, res) => { if(err)  theErr = err; // to rethrow in caller if(res) console.log(res.value); } ); if(theErr) // rethrow throw theErr; return h.response(result.value); } catch (e) { console.log(e); return h.response(e.toString()); } }
            michael.reiche Michael Reiche made changes -
            Priority Major [ 3 ] Minor [ 4 ]
            brett19 Brett Lawson made changes -
            Status New [ 10003 ] Open [ 1 ]
            brett19 Brett Lawson made changes -
            Fix Version/s 3.0.1 [ 16659 ]
            avsej Sergey Avseyev made changes -
            Link This issue depends on CCBC-1158 [ CCBC-1158 ]

            The 'UnhandledPromiseRejection' can be resolved by chaining a 'catch' on to the collections.get() call :

            return collection.get(docKey, {timeout: 1000},
                        (err, res) =>

            {                 if(res) console.log(res);             }

            ).catch((e)=>{console.log(e); return h.response(e.toString()"<pre>"+e.stack"</pre>");});

            michael.reiche Michael Reiche added a comment - The 'UnhandledPromiseRejection' can be resolved by chaining a 'catch' on to the collections.get() call : return collection.get(docKey, {timeout: 1000},             (err, res) => {                 if(res) console.log(res);             } ).catch((e)=>{console.log(e); return h.response(e.toString() "<pre>"+e.stack "</pre>");});
            brett19 Brett Lawson made changes -
            Fix Version/s 3.0.2 [ 16736 ]
            Fix Version/s 3.0.1 [ 16659 ]
            brett19 Brett Lawson made changes -
            Story Points 1
            brett19 Brett Lawson made changes -
            Component/s lcb [ 15854 ]
            brett19 Brett Lawson made changes -
            Fix Version/s 3.0.3 [ 16796 ]
            Fix Version/s 3.0.2 [ 16736 ]
            brett19 Brett Lawson made changes -
            Fix Version/s 3.0.7 [ 17049 ]
            Fix Version/s 3.0.6 [ 16796 ]
            brett19 Brett Lawson made changes -
            Fix Version/s 3.0.6 [ 16796 ]
            Fix Version/s 3.0.7 [ 17049 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Resolved [ 5 ]

            People

              brett19 Brett Lawson
              michael.reiche Michael Reiche
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty