We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d252bfc commit f29084fCopy full SHA for f29084f
src/index.js
@@ -112,7 +112,11 @@ module.exports = function (connect) {
112
options.mongooseConnection.once('open', () => this.handleNewConnectionAsync(options.mongooseConnection))
113
}
114
} else if (options.client) {
115
- this.handleNewConnectionAsync(options.client)
+ if (options.client.isConnected()) {
116
+ this.handleNewConnectionAsync(options.client)
117
+ } else {
118
+ options.client.once('open', () => this.handleNewConnectionAsync(options.client))
119
+ }
120
} else if (options.clientPromise) {
121
options.clientPromise
122
.then(client => this.handleNewConnectionAsync(client))
0 commit comments