Skip to content

Commit fd14895

Browse files
committed
fix: cursor should run getMore if init command returned 0 documents
1 parent 6b38312 commit fd14895

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
@@ -720,7 +720,9 @@ export abstract class AbstractCursor<
720720

721721
if (this[kId] == null) {
722722
await this.cursorInit();
723-
return;
723+
// If the cursor died or returned documents, return
724+
if (this[kDocuments].length !== 0 || this.isDead) return;
725+
// Otherwise, run a getMore
724726
}
725727

726728
// otherwise need to call getMore
@@ -868,6 +870,11 @@ class ReadableCursorStream extends Readable {
868870
}
869871

870872
private _readNext() {
873+
if (this._cursor[kId] === Long.ZERO) {
874+
this.push(null);
875+
return;
876+
}
877+
871878
// eslint-disable-next-line github/no-then
872879
this._cursor.next().then(
873880
result => {

0 commit comments

Comments
 (0)