Skip to content

Commit c2a18e4

Browse files
committed
fix: cursor should run getMore if init command returned 0 documents
1 parent f38035b commit c2a18e4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/cursor/abstract_cursor.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,9 @@ export abstract class AbstractCursor<
708708

709709
if (this[kId] == null) {
710710
await this.cursorInit();
711-
return;
711+
// If the cursor died or returned documents, return
712+
if (this[kDocuments].length !== 0 || this.isDead) return;
713+
// Otherwise, run a getMore
712714
}
713715

714716
// otherwise need to call getMore
@@ -856,6 +858,11 @@ class ReadableCursorStream extends Readable {
856858
}
857859

858860
private _readNext() {
861+
if (this._cursor[kId] === Long.ZERO) {
862+
this.push(null);
863+
return;
864+
}
865+
859866
// eslint-disable-next-line github/no-then
860867
this._cursor.next().then(
861868
result => {

0 commit comments

Comments
 (0)