-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.3.2
-
Component/s: None
-
Environment:MongoDB driver 3.3.2, local replica set running server 4.0.6. No transpilers, no Mongoose.
-
Empty show more show less
The below script succeeds when using `useUnifiedTopology`, but reports a "server instance pool was destroyed" error if `useUnifiedTopology` is off.
const { MongoClient } = require('mongodb'); run().catch(err => console.log(err)); async function run() { const client = await MongoClient.connect('mongodb://localhost:27017/test', { useNewUrlParser: true, useUnifiedTopology: true }); const db = client.db(); await client.close(true); await db.collection('Test').insertOne({ x: 1 }); console.log('done'); }
It looks like the unified topology.js doesn't do anything with the `force` option: https://github.com/mongodb/node-mongodb-native/blob/f6e854ceb7644eefd71789e084f4c46e3e2b4da3/lib/core/sdam/topology.js#L277-L278
`db.isMaster()` output:
{ "hosts" : [ "localhost:27017", "localhost:27018", "localhost:27019" ], "setName" : "rs", "setVersion" : 1, "ismaster" : true, "secondary" : false, "primary" : "localhost:27017", "me" : "localhost:27017", "electionId" : ObjectId("7fffffff0000000000000001"), "lastWrite" : { "opTime" : { "ts" : Timestamp(1568041368, 1), "t" : NumberLong(1) }, "lastWriteDate" : ISODate("2019-09-09T15:02:48Z"), "majorityOpTime" : { "ts" : Timestamp(1568041368, 1), "t" : NumberLong(1) }, "majorityWriteDate" : ISODate("2019-09-09T15:02:48Z") }, "maxBsonObjectSize" : 16777216, "maxMessageSizeBytes" : 48000000, "maxWriteBatchSize" : 100000, "localTime" : ISODate("2019-09-09T15:02:52.734Z"), "logicalSessionTimeoutMinutes" : 30, "minWireVersion" : 0, "maxWireVersion" : 7, "readOnly" : false, "ok" : 1, "operationTime" : Timestamp(1568041368, 1), "$clusterTime" : { "clusterTime" : Timestamp(1568041368, 1), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } } }