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

3.6.3: MongoServerSelectionError when used with useUnifiedTopology

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.6.3
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      MongoDB Driver 3.6.3 throws `UnhandledPromiseRejectionWarning: MongoServerSelectionError: Server selection timed out after 30000 ms` if you connect to the MongoDB server that has a replication set when used with useUnifiedTopology.

       

      Complete reproduction repo: https://github.com/rmehner/mongo-3.6.3-bug

      Steps to reproduce:

      1. Install MongoDB driver 3.6.3
      2. Start MongoDB server 4.4.3 with `mongod --bind_ip_all --replSet rs0`
      3. Connect to MongoDB via node:

      ```js

      const { MongoClient, connect } = require("mongodb");

      const client = new MongoClient("mongodb://localhost:27017",

      { useUnifiedTopology: true, }

      );

      (async () =>

      { const connection =await client.connect(); console.log("If you see this, the connection was successful �"); await connection.close() process.exit(0); }

      )();
      ```

        1. Expected

      Successful connection and the message "If you see this, the connection was successful �"

        1. Actual

      UnhandledPromiseRejectionWarning: MongoServerSelectionError: Server selection timed out after 30000 ms

        1. Fixes

      Either downgrade to driver version 3.6.2 or remove the useUnifiedTopology option in the connection options.

       

      Thank you for looking into this

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            robin@coding-robin.de Robin Mehner
            None
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: