-
Type: Bug
-
Resolution: Duplicate
-
Priority: Blocker - P1
-
None
-
Affects Version/s: None
-
Component/s: None
-
Empty show more show less
-
Not Needed
Encountered an error when trying to use changeStream when running "changeStream.on('change',..."):
error: "MongoServerError: Cursor session id (83bd3b49-cca9-4a9d-ab34-b8dc979b8010 - YtJ8CVGJPpojGlBhlVfpmkB+TWiGCwPUvkGEjp5tty0=) is not the same as the operation context's session id (none)"
When running over MongoDB NodeJS Driver 3.6.10 this issue disapear!
My environment:
- NodeJS v16.6.1
- MongoDB Community Server 5.0.2
- MongoDB Driver NodeJS v4.1
- ReplSet 2 nodes
mongod.conf:
storage: dbPath: /var/lib/mongodb journal: enabled: true systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log net: port: 27017 bindIp: 127.0.0.1,10.1.1.12 processManagement: timeZoneInfo: /usr/share/zoneinfo security: authorization: enabled keyFile: /var/lib/mongodb-pki/keyfile operationProfiling: mode: "slowOp" slowOpThresholdMs: 50 replication: replSetName: rs0
My code:
const { MongoClient } = require("mongodb"), user = encodeURIComponent(process.env.DB_USER), pass = encodeURIComponent(process.env.DB_PASS), host = process.env.DB_HOST, port = process.env.DB_PORT, uri = `mongodb://${user}:${pass}@${host}:${port}/?replicaSet=rs0`, options = { useNewUrlParser: true, useUnifiedTopology: true }, client = new MongoClient(uri, options); client.connect(); const db = client.db('flexograv'), collection = db.collection('jobs'), pipeline = [{ '$match': { 'operationType': 'insert' }}], changeStream = collection.watch(pipeline); changeStream.on('change', change => { console.log({ change: change }); }); changeStream.on('error', error => { console.log({ error: `${error}` }); });
- duplicates
-
NODE-3536 Cached Driver in FAAS Environments
- Closed