Skip to content

Commit f39ebac

Browse files
committed
fix: make sure close does not end early but killed does
1 parent c2a18e4 commit f39ebac

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/cursor/abstract_cursor.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,11 @@ export abstract class AbstractCursor<
300300

301301
try {
302302
while (true) {
303-
if (this.closed) {
303+
if (this.killed) {
304+
return;
305+
}
306+
307+
if (this.closed && this[kDocuments].length === 0) {
304308
return;
305309
}
306310

test/integration/crud/misc_cursors.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1870,7 +1870,7 @@ describe('Cursor', function () {
18701870
const rejectedEarlyBecauseClientClosed = cursor.next().catch(error => error);
18711871

18721872
await client.close();
1873-
expect(cursor).to.have.property('killed', true);
1873+
expect(cursor).to.have.property('closed', true);
18741874

18751875
const error = await rejectedEarlyBecauseClientClosed;
18761876
expect(error).to.be.instanceOf(MongoExpiredSessionError);

0 commit comments

Comments
 (0)