Skip to content

Commit 91c7353

Browse files
committed
1 parent 5bd60ec commit 91c7353

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,14 @@ class Mongoose {
9393
// <https://github.com/Automattic/mongoose/issues/12970>
9494
//
9595
connection.asPromise = function () {
96-
if (!this.$initialConnection)
97-
return this.openUri(this._connectionString, this._connectionOptions);
96+
if (
97+
!this.$initialConnection ||
98+
this.readyState === mongoose.ConnectionStates.disconnected
99+
)
100+
this.$initialConnection = this.openUri(
101+
this._connectionString,
102+
this._connectionOptions
103+
);
98104
return this.$initialConnection;
99105
};
100106

0 commit comments

Comments
 (0)