Skip to content

Commit

Permalink
fix(connection): avoid setting MongoClient on useDb() connections unt…
Browse files Browse the repository at this point in the history
…il after setting on base connection

Fix #11445
  • Loading branch information
vkarpov15 committed Mar 12, 2022
1 parent 86a12ae commit 5bdd836
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 @@ -788,10 +788,6 @@ Connection.prototype.openUri = function(uri, options, callback) {
}
_this.client = client;

for (const db of this.otherDbs) {
_setClient(db, client, {}, db.name);
}

client.setMaxListeners(0);
client.connect((error) => {
if (error) {
Expand All @@ -800,6 +796,10 @@ Connection.prototype.openUri = function(uri, options, callback) {

_setClient(_this, client, options, dbName);

for (const db of this.otherDbs) {
_setClient(db, client, {}, db.name);
}

resolve(_this);
});
});
Expand Down

0 comments on commit 5bdd836

Please sign in to comment.