-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: Native
-
None
-
Empty show more show less
From the change streams spec:
startAtOperationTime and resumeAfter are mutually exclusive; if both startAtOperationTime and resumeAfter are set, the server will return an error. Drivers MUST NOT throw a custom error, and MUST defer to the server error.
Currently, if a user specifies resumeAfter and startAtOperationTime, it looks like only the resumeAfter token is sent. Based on the spec, both should be passed so the server can return an error.
Here's a silly repro:
const MongoClient = require('./node-mongodb-native').MongoClient; MongoClient.connect("mongodb://localhost:27017/?replicaSet=rs", { useNewUrlParser: true }).then((client) => { const db = client.db('test'); const session = client.startSession(); /* do something to set an operation time on the session. */ db.collection('test').find({}, { session: session }); const changeStream = db.collection('test').watch([], { session: session, startAtOperationTime: session.operationTime, }); changeStream.on('change', (change) => { const cachedResumeToken = change["_id"]; console.log('start another change stream'); const secondChangeStream = db.collection('test').watch([], { session: session, startAtOperationTime: session.operationTime, resumeAfter: cachedResumeToken }); secondChangeStream.on('change', (change) => { console.log('second change stream got', change); }); changeStream.close(); }); });