Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-1197

Cursor: When Cursor is exhaust hasNext() function returns error instead 'false' when it is called more than once.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 2.2.33
    • Fix Version/s: None
    • Component/s: MongoDB 3.4
    • Environment:
      linux ubuntu 16
      Nodejs 8.9.1

      Description

      In the next code:

      const cursor = db.collection('myCollection').aggregate([ a pipeline that produce empty elements ]);
      const a = await cursor.hasNext();
      const b = await cursor.hasNext();
      const c = await cursor.hasNext();
      

      The variable 'a' contains false. However an error is thrown in line 3. this error is:

      {
      message:"cursor is exhausted"
      stack:   "Error: cursor is exhausted
        at nextFunction (/my_project/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:521:21)
        at AggregationCursor.Cursor.next [as _next] (/my_project/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:699:3)
        at nextObject (/my_project/node_modules/mongodb/lib/cursor.js:680:8)
        at AggregationCursor.Cursor.hasNext (/my_project/node_modules/mongodb/lib/cursor.js:223:14)
        at Promise (/my_project/lib/components/stay-area/stay-area-entity-object.js:170:14)
        at new Promise (<anonymous>)
        at StayAreaEntityObject.cursorHasNext (/my_project/lib/components/stay-area/stay-area-entity-object.js:169:12)
        at StayAreaEntityObject.getTimeByArea (/my_project/lib/components/stay-area/stay-area-entity-object.js:122:36)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:188:7)"
      }
      

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: