-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: 3.6.5
-
Component/s: None
In this exampe we filter the ChangeMessages rather strictly (only delete messages are allowed to be returned) and we start at a specific Entrypoint (for reproduction you need to specify an own entrypoint for this )
==> MongoDB will start to query the oplog for delete -changemessages. This can take some time, depending on the count of messages from starting-point to the first delete-message.
==> Before the first returning data (MongoDB is still querying) the ChangeStream is closed.
Expected Behaviour:
The Next-Call rejects with a "MongoError - Closed" instantly (or in "near" future at least).
Actual Behaviour:
The Next-Call rejects with a "MongoError - Closed" after quite some time (most likly after the initial query for the changestream is finished).
Running the Script (with multiple Millions of Inserts between Entrypoint and Head of te Oplog):
closed!
default: 5:20.648 (m:ss.mmm)
import {MongoClient} from "mongodb"; async function main(): Promise<void> { const client = await MongoClient.connect('mongodb://localhost:27017'); const changeStream = client.watch([ {$match: {operationType: 'delete'}} ], { resumeAfter: {_data: "82604F45E4000010452B022C0100296E5A1004B3CAF2964D1040069D88BCB4BD88DF91465A5F6964005A10049439945EFADA4818B6B5F9766ED13A310004"}, }); const next = changeStream.next(); await changeStream.close(); console.time(); console.log("closed!"); try { await next; } catch (err) { // Closed error will be thrown here } finally { console.timeEnd(); } process.exit(); } main().catch(console.error);