From 3d2345f524437d09eeb0c6423ea8b044b5818080 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 22 Feb 2021 16:22:25 -0500 Subject: [PATCH] fix(connection): set connection state to `disconnected` if connecting string failed to parse Fix #9921 --- lib/connection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/connection.js b/lib/connection.js index 0f646b72b42..2f6214b088b 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -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); } @@ -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); }