-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.3.3
-
Component/s: None
This issue appeared in v3.3.3. The below script prints 'Emitted close' over and over:
'use strict'; const mongodb = require('mongodb'); run().catch(error => console.log('Caught', error)); async function run() { const uri = 'mongodb://localhost:27017,localhost:27018,localhost:27019/test?replicaSet=rs'; const client = await mongodb.MongoClient.connect(uri, { useNewUrlParser: true, useUnifiedTopology: true }); console.log('Connected'); client.on('close', () => console.log('Emitted close')); }
If it either connects to a replica set when one member is down, or if it loses connectivity to a member of a replica set.
Related to: https://github.com/Automattic/mongoose/issues/8224