Skip to content

Commit

Permalink
fix(connection): set connection state to disconnected if connecting…
Browse files Browse the repository at this point in the history
… string failed to parse

Fix #9921
  • Loading branch information
vkarpov15 committed Feb 22, 2021
1 parent 70bd798 commit 3d2345f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,6 @@ Connection.prototype.openUri = function(uri, options, callback) {
_this.client = client;
client.connect((error) => {
if (error) {
_this.readyState = STATES.disconnected;
return reject(error);
}

Expand All @@ -846,6 +845,7 @@ Connection.prototype.openUri = function(uri, options, callback) {
this.$initialConnection = Promise.all([promise, parsePromise]).
then(res => res[0]).
catch(err => {
this.readyState = STATES.disconnected;
if (err != null && err.name === 'MongoServerSelectionError') {
err = serverSelectionError.assimilateError(err);
}
Expand Down

0 comments on commit 3d2345f

Please sign in to comment.