Skip to content

Commit

Permalink
test: fix one test re: #8383
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Nov 26, 2019
1 parent 68cdc33 commit e6616d7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/connection.js
Expand Up @@ -670,6 +670,7 @@ Connection.prototype.openUri = function(uri, options, callback) {
if (options.useUnifiedTopology) {
if (type === 'Single') {
const server = Array.from(db.s.topology.s.servers.values())[0];

server.s.pool.on('close', () => {
_this.readyState = STATES.disconnected;
});
Expand All @@ -682,6 +683,11 @@ Connection.prototype.openUri = function(uri, options, callback) {
server.s.pool.on('timeout', () => {
_this.emit('timeout');
});
server.s.pool.on('drain', err => {
if (err && err.name === 'MongoNetworkError') {
_this.emit('timeout');
}
});
} else if (type.startsWith('ReplicaSet')) {
db.on('close', function() {
const type = get(db, 's.topology.s.description.type', '');
Expand Down

0 comments on commit e6616d7

Please sign in to comment.