Skip to content

Commit

Permalink
Listening to events on the DB object is deprecated in v3.x and will b…
Browse files Browse the repository at this point in the history
…e unsupported in v4 of the mongodb drivers. Adjusted remaining listeneers to use the DB client object, as per the MongoDB Driver API docs
  • Loading branch information
Colin Hill committed Mar 8, 2021
1 parent 5277d24 commit bdb862f
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 bdb862f

Please sign in to comment.