-
Type: Bug
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.3.2
-
Component/s: None
-
Labels:
-
Empty show more show less
I'm setting up a change stream using $divide with the code below, and I'm getting an error I can't make sense of. The errors occur if I connect (from the same machine) to our mLab production instance running 3.6.12 (WiredTiger), but not if I connect to a development replica set running 4.0.9.
let count = 0; const changeStream = collection.watch( [ { $replaceRoot: { newRoot: '$fullDocument' } }, { $addFields: { ratios: [{ $divide: ['$foo', '$bar'] }] } }, { $match: { 'ratios.0': { $lte: 99999 } } }, ], { fullDocument: 'updateLookup' } ); changeStream.on('change', async next => { process.stdout.write(`\u001b[2K${(count++)}\u001b[0E`); });
The change stream creation code doesn't pass any resumeAfter parameter, yet the error reads: BSON field '$changeStream.resumeAfter' is the wrong type 'string', expected type 'object'. This error occurs reliably every time I run the script, though the count appears to be random, from ~25 to over 200
$uname -a4.4.0-159-generic #187-Ubuntu SMP Thu Aug 1 16:28:06 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux$ node -v v12.10.0 15:05:02 [0s] @project:~/project/backend$ npm list mongodb project@5.3.1 /home/dandv/project/backend ├─┬ agenda@2.1.0 │ └── mongodb@3.2.7 └── mongodb@3.3.2 15:05:10 [5s] @project:~/project/backend$ ./notifier.mjs $ ./notifier.mjs (node:24059) ExperimentalWarning: The ESM module loader is experimental. events.js:186 throw er; // Unhandled 'error' event ^MongoError: BSON field '$changeStream.resumeAfter' is the wrong type 'string', expected type 'object' at Connection.<anonymous> (/home/dandv/project/backend/node_modules/mongodb/lib/core/connection/pool.js:466:61) at Connection.emit (events.js:209:13) at processMessage (/home/dandv/project/backend/node_modules/mongodb/lib/core/connection/connection.js:364:10) at TLSSocket.<anonymous> (/home/dandv/project/backend/node_modules/mongodb/lib/core/connection/connection.js:533:15) at TLSSocket.emit (events.js:209:13) at addChunk (_stream_readable.js:305:12) at readableAddChunk (_stream_readable.js:286:11) at TLSSocket.Readable.push (_stream_readable.js:220:10) at TLSWrap.onStreamRead (internal/stream_base_commons.js:182:23) Emitted 'error' event on ChangeStream instance at: at processNewChange (/home/dandv/project/backend/node_modules/mongodb/lib/change_stream.js:535:43) at ChangeStreamCursor.<anonymous> (/home/dandv/project/backend/node_modules/mongodb/lib/change_stream.js:420:5) at ChangeStreamCursor.emit (events.js:209:13) at /home/dandv/project/backend/node_modules/mongodb/lib/core/cursor.js:344:16 at /home/dandv/project/backend/node_modules/mongodb/lib/core/cursor.js:750:9 at /home/dandv/project/backend/node_modules/mongodb/lib/change_stream.js:303:9 at done (/home/dandv/project/backend/node_modules/mongodb/lib/core/cursor.js:463:7) at /home/dandv/project/backend/node_modules/mongodb/lib/core/cursor.js:547:11 at /home/dandv/project/backend/node_modules/mongodb/lib/operations/execute_operation.js:76:14 at executeCallback (/home/dandv/project/backend/node_modules/mongodb/lib/operations/execute_operation.js:67:25) { operationTime: Timestamp { _bsontype: 'Timestamp', low_: 9, high_: 1568401561 }, ok: 0, errmsg: "BSON field '$changeStream.resumeAfter' is the wrong type 'string', expected type 'object'", code: 14, codeName: 'TypeMismatch', '$clusterTime': { clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 9, high_: 1568401561 }, signature: { hash: [Binary], keyId: [Long] } }, name: 'MongoError', [Symbol(mongoErrorContextSymbol)]: {} }