-
Type:
Bug
-
Resolution: Works as Designed
-
Priority:
Major - P3
-
None
-
Affects Version/s: 3.6.3
-
Component/s: 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); })();
```
-
- Expected
Successful connection and the message "If you see this, the connection was successful �"
-
- Actual
UnhandledPromiseRejectionWarning: MongoServerSelectionError: Server selection timed out after 30000 ms
-
- Fixes
Either downgrade to driver version 3.6.2 or remove the useUnifiedTopology option in the connection options.
Thank you for looking into this