-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: 3.5.4
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I was testing with the new topology mechanism and encountered an error.
The idea is to execute the query if the server is available or throw an error after a timeout if not available.
Here is the code i used :
const MongoClient = require("mongodb"); const main = async () => { const client = await MongoClient("mongodb://127.0.0.1", { useUnifiedTopology: true }); const coll = client.db("test").collection("test"); setInterval(async () => { try { console.log(await coll.findOne({})); } catch (err) { console.log(err); } }, 1000);}; main();
And the output :
// [server is up, queries are running fine]null
null
null
null
null
null
null
null
null
null
null
null// [stopped the server, coll.findOne is pending with serverSelectionTimeoutMS]// [started back up the server before the serverSelectionTimeoutMS expired]
/Users/hay/Desktop/nodejs-mongo-driver/node_modules/mongodb/lib/core/sdam/topology.js:1001
if (waitQueueMember[kCancelled]) {
^
TypeError: Cannot read property 'Symbol(cancelled)' of undefined
at processWaitQueue (/Users/hay/Desktop/nodejs-mongo-driver/node_modules/mongodb/lib/core/sdam/topology.js:1001:24)
at NativeTopology.serverUpdateHandler (/Users/hay/Desktop/nodejs-mongo-driver/node_modules/mongodb/lib/core/sdam/topology.js:550:7)
at Server.emit (events.js:321:20)
at Monitor.<anonymous> (/Users/hay/Desktop/nodejs-mongo-driver/node_modules/mongodb/lib/core/sdam/server.js:147:12)
at Monitor.emit (events.js:333:22)
at successHandler (/Users/hay/Desktop/nodejs-mongo-driver/node_modules/mongodb/lib/core/sdam/monitor.js:154:13)
at /Users/hay/Desktop/nodejs-mongo-driver/node_modules/mongodb/lib/core/sdam/monitor.js:196:5
at callback (/Users/hay/Desktop/nodejs-mongo-driver/node_modules/mongodb/lib/core/connection/connect.js:97:5)
at /Users/hay/Desktop/nodejs-mongo-driver/node_modules/mongodb/lib/core/connection/connect.js:169:5
at /Users/hay/Desktop/nodejs-mongo-driver/node_modules/mongodb/lib/core/connection/connect.js:334:7
- is related to
-
NODE-2480 TypeError after reconnecting
-
- Closed
-