-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
None
-
Affects Version/s: 2.2.33
-
Component/s: MongoDB 3.4
-
Environment:linux ubuntu 16
Nodejs 8.9.1
-
Empty show more show less
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)" }