Skip to content

Commit c9d6c3a

Browse files
authored
Merge pull request #10004 from hillct/master
Fix Event Listeners to comply with (new v3 & v4) MongoDB Driver API changes
2 parents c2582d5 + bdb862f commit c9d6c3a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/connection.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ function _setClient(conn, client, options, dbName) {
929929
}
930930
});
931931

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

947947
if (!options.useUnifiedTopology) {
948-
db.on('reconnect', function() {
948+
client.on('reconnect', function() {
949949
_handleReconnect();
950950
});
951951

@@ -965,7 +965,7 @@ function _setClient(conn, client, options, dbName) {
965965
});
966966
}
967967
if (!options.useUnifiedTopology) {
968-
db.on('close', function() {
968+
client.on('close', function() {
969969
// Implicitly emits 'disconnected'
970970
conn.readyState = STATES.disconnected;
971971
});
@@ -984,7 +984,7 @@ function _setClient(conn, client, options, dbName) {
984984
}
985985
});
986986

987-
db.on('timeout', function() {
987+
client.on('timeout', function() {
988988
conn.emit('timeout');
989989
});
990990
}

0 commit comments

Comments
 (0)