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

Replica set connection not closed if close called immediately

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.2.3
    • Component/s: None
    • Labels:

       

      Connection not closed if close called immediately after connecting to a replica set.

      Introducing a Timeout delay allows the connection to be closed.

      const
          MongoClient = require("mongodb").MongoClient;
      
      const mongodb_con_str =
          "mongodb://" +
          "localhost:27018,localhost:27019,localhost:27020" +
          "/test" +
          "?replicaSet=rs0";
      
      const mongodb_con_opts = { "useNewUrlParser": true };
      
      
      
      MongoClient.connect(mongodb_con_str, mongodb_con_opts)
      
      .then(
      
          mongo => Promise.reject()
      
          .then(
              _ => console.log("Program OK"),
              _ => console.log("Program error")
          )
      
          // Adding a delay allows MongoClient.close()
          // to close the connection.
      
          //.then(_ => new Promise(r => setTimeout(r, 0)))
      
          .then(_ => mongo.close()))
      
      .catch(e => console.log("Program ended with error", e));
      
      

       

            Assignee:
            daniel.aprahamian@mongodb.com Daniel Aprahamian (Inactive)
            Reporter:
            simony Simon Yarde
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: