-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: js-bson
-
None
-
Empty show more show less
Steps to repro:
1. Using mongodb 3.6 rc1, node v8.8.1, npm 5.4.2
2. Get a replicate set created
3. Using the following package.json
{ "dependencies": { "mongodb": "mongodb/node-mongodb-native#3.0.0" } }
4. And the following index.js file
const { MongoClient } = require('mongodb'); const uri = 'mongodb://localhost:27017/chat'; const pipeline = [ { $match: { operationType: { $in: ['insert', 'replace'] } } }, ]; async function connect() { const client = await MongoClient.connect(uri); const db = client.db('chat'); const collection = db.collection('messages'); const changeStream = collection.watch(pipeline); changeStream.on('change', change => { console.log('Change', change); }); await collection.insert({ id: 1, name: 'harry', time: new Date() }); setTimeout(() => { process.exit(0); }, 1000); } connect().catch(err => console.dir(err, { depth: 5 }));
5. Executing `node index.js` results in the following stack trace:
➜ ~/Sites/weather-chat git:(master) ✗ node index.js
Error: key $clusterTime must not start with '$'
at serializeInto (/Users/hswolff/Sites/weather-chat/node_modules/bson/lib/bson/parser/serializer.js:751:19)
at BSON.serialize (/Users/hswolff/Sites/weather-chat/node_modules/bson/lib/bson/bson.js:58:27)
at Query.toBin (/Users/hswolff/Sites/weather-chat/node_modules/mongodb/node_modules/mongodb-core/lib/connection/commands.js:141:25)
at serializeCommands (/Users/hswolff/Sites/weather-chat/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:1016:43)
at Pool.write (/Users/hswolff/Sites/weather-chat/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:1185:3)
at executeWrite (/Users/hswolff/Sites/weather-chat/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js:75:10)
at WireProtocol.insert (/Users/hswolff/Sites/weather-chat/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js:86:3)
at Server.insert (/Users/hswolff/Sites/weather-chat/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:737:35)
at Server.insert (/Users/hswolff/Sites/weather-chat/node_modules/mongodb/lib/topologies/topology_base.js:322:25)
at executeBatch (/Users/hswolff/Sites/weather-chat/node_modules/mongodb/lib/bulk/unordered.js:478:23)
Should these modules be using the 2.0 branch of BSON instead of the 1.0 branch?