Skip to content

Commit 8c287de

Browse files
committed
sharded clusters have an internal oplog cursor
1 parent 2862e8f commit 8c287de

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

test/integration/node-specific/client_close.test.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -742,17 +742,20 @@ describe('MongoClient.close() Integration', () => {
742742
metadata,
743743
async function () {
744744
const getCursors = async () => {
745-
const res = await utilClient
746-
.db()
747-
.admin()
748-
.command({
745+
const cursors = await utilClient
746+
.db('admin')
747+
.runCursorCommand({
749748
aggregate: 1,
750749
cursor: {},
751750
pipeline: [{ $currentOp: { idleCursors: true } }]
752-
});
753-
return res.cursor.firstBatch.filter(
754-
r => r.type === 'idleCursor' || (r.type === 'op' && r.desc === 'getMore')
755-
);
751+
})
752+
.toArray();
753+
754+
return [
755+
...cursors.filter(c => c.type === 'idleCursor'), // all idle cursors
756+
...cursors.filter(c => c.type === 'op' && c.desc === 'getMore'), // all running getMores
757+
...cursors.filter(c => c.ns !== 'local.oplog.rs') // no internal oplog cursors (sharded clusters)
758+
];
756759
};
757760

758761
cursor = coll.find({}, { batchSize: 1 });

0 commit comments

Comments
 (0)