File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import * as sinon from 'sinon';
33
44import {
55 Code ,
6- CursorResponse ,
76 Long ,
87 type MongoClient ,
98 MongoServerError ,
@@ -1083,18 +1082,17 @@ describe('Find', function () {
10831082 await collection . deleteMany ( { } ) ;
10841083 await collection . insertMany ( Array . from ( { length : 4 } , ( _ , i ) => ( { x : i } ) ) ) ;
10851084
1086- const getMoreSpy = sinon . spy ( CursorResponse , 'emptyGetMore' , [ 'get' ] ) ;
1087-
10881085 const cursor = collection . find ( { } , { batchSize : 1 , limit : 3 } ) ;
10891086 // emptyGetMore is used internally after limit + 1 documents have been iterated
10901087 await cursor . next ( ) ;
10911088 await cursor . next ( ) ;
10921089 await cursor . next ( ) ;
10931090 await cursor . next ( ) ;
10941091
1095- // assert that `emptyGetMore` is called. if it is not, this test
1096- // always passes, even without the fix in NODE-6878.
1097- expect ( getMoreSpy . get ) . to . have . been . called ;
1092+ // On servers < 9.0, mongos returns a non-zero cursorId even after the limit
1093+ // is satisfied, so the driver uses CursorResponse.emptyGetMore to avoid a
1094+ // wasted getMore. On 9.0+, mongos returns cursorId: 0 when the limit is
1095+ // reached. In both cases, rewinding and re-iterating the cursor must work.
10981096
10991097 cursor . rewind ( ) ;
11001098
You can’t perform that action at this time.
0 commit comments