Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-2472

TypeError on server available with useUnifiedTopology: true

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.5
    • Affects Version/s: 3.5.4
    • Component/s: 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
      

            Assignee:
            matt.broadstone@mongodb.com Matt Broadstone
            Reporter:
            hugo.alamercery@imhotepcreation.com Hugo Alamercery
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: