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.

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

      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)"
      }
      

            Assignee:
            rebecca.weinberger Rebecca Weinberger
            Reporter:
            necrifede Nestor Felipe
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: