-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.4.1
-
Component/s: MongoDB 3.4
-
Environment:node:11-alpine
-
Empty show more show less
Replset events are no longer emitted after upgrade from 3.1.15 to 3.4.1 (and also 3.3.1). In particular, the "left" event.
// connect function this.mainClient = await MongoClient.connect(settings.db.url, options); this.mainDB = this.mainClient.db(settings.db.name); const onLeft = (event: any) => { logger.error(`Lost connection to mongodb replica: ${event}.`); }; this.mainClient.on("left", onLeft);
Options are:
{ useNewUrlParser: true, useUnifiedTopology: true, auth: { user: 'notrealuser', password: 'notrealpassword' }, replicaSet: 'ReplSet', readPreference: 'primaryPreferred' }
Running in the node11:alpine docker image.
Tested this by shutting down a single instance replset and bringing it back up on version 3.1.15 and 3.4.1 with identical code. In 3.1.15 the event fires but in 3.4.1 it does not.