Skip to content

Commit

Permalink
Merge pull request #10004 from hillct/master
Browse files Browse the repository at this point in the history
Fix Event Listeners to comply with (new v3 & v4) MongoDB Driver API changes
  • Loading branch information
vkarpov15 authored Mar 10, 2021
2 parents c2582d5 + bdb862f commit c9d6c3a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ function _setClient(conn, client, options, dbName) {
}
});

db.on('close', function() {
client.on('close', function() {
const type = get(db, 's.topology.s.description.type', '');
if (type !== 'ReplicaSetWithPrimary') {
// Implicitly emits 'disconnected'
Expand All @@ -945,7 +945,7 @@ function _setClient(conn, client, options, dbName) {
});

if (!options.useUnifiedTopology) {
db.on('reconnect', function() {
client.on('reconnect', function() {
_handleReconnect();
});

Expand All @@ -965,7 +965,7 @@ function _setClient(conn, client, options, dbName) {
});
}
if (!options.useUnifiedTopology) {
db.on('close', function() {
client.on('close', function() {
// Implicitly emits 'disconnected'
conn.readyState = STATES.disconnected;
});
Expand All @@ -984,7 +984,7 @@ function _setClient(conn, client, options, dbName) {
}
});

db.on('timeout', function() {
client.on('timeout', function() {
conn.emit('timeout');
});
}
Expand Down

0 comments on commit c9d6c3a

Please sign in to comment.