From f23d9fe9bd796fbe72f1cf2ff5fe502bc29d568f Mon Sep 17 00:00:00 2001 From: jdgjsag67251 <88368191+jdgjsag67251@users.noreply.github.com> Date: Tue, 25 Apr 2023 12:41:03 +0200 Subject: [PATCH] Added test (#12587) --- packages/mongo/collection_tests.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packages/mongo/collection_tests.js b/packages/mongo/collection_tests.js index fb92fb8b79..de4fd16c91 100644 --- a/packages/mongo/collection_tests.js +++ b/packages/mongo/collection_tests.js @@ -414,3 +414,31 @@ Tinytest.add('collection - count should release the session', test.equal(preCount, postCount); } ); + +Tinytest.addAsync('collection - should not block on cursor mismatch (#12516)', + async function(test) { + if (!Meteor.isServer) { + return; + } + + // Setup + const collection = new Mongo.Collection('test' + test.id); + Array.from({ length: 5 }).forEach((_, i) => { + collection.insert({ name: "Test-" + i }); + }); + + // Test + const cursor = collection.find({ name: undefined }); + + let subscription; + const promise = new Promise((resolve) => { + setTimeout(() => { + test.ok(!!subscription); + resolve(); + }, 500); + }); + subscription = cursor.observe({}); + subscription.stop(); + await promise; + } +);