Skip to content

Commit f29084f

Browse files
jaredhansonmingchuno
authored andcommittedJun 15, 2019
Wait for client open, before calling db. (#321)
1 parent d252bfc commit f29084f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎src/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ module.exports = function (connect) {
112112
options.mongooseConnection.once('open', () => this.handleNewConnectionAsync(options.mongooseConnection))
113113
}
114114
} else if (options.client) {
115-
this.handleNewConnectionAsync(options.client)
115+
if (options.client.isConnected()) {
116+
this.handleNewConnectionAsync(options.client)
117+
} else {
118+
options.client.once('open', () => this.handleNewConnectionAsync(options.client))
119+
}
116120
} else if (options.clientPromise) {
117121
options.clientPromise
118122
.then(client => this.handleNewConnectionAsync(client))

0 commit comments

Comments
 (0)
Please sign in to comment.