-
ContextI've developed an API hosted on a service that stops if there's no call after a certain amount of time and starts as soon as a new request arrives. Currently, when the service starts, I connect to my database with this code: QuestionSo I was wondering what would happen if I removed the code that makes sure the connection is ready before accepting an HTTP request. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Presuming you already called mongoose.connect(), the MongoDB node driver will automatically retry any queries for up to serverSelectionTimeoutMS (30 seconds by default). So your find() call will wait until mongoose.connect() succeeds up to a certain timeout. If it takes more than 30 seconds to connect, your find() will error out |
Beta Was this translation helpful? Give feedback.
Presuming you already called mongoose.connect(), the MongoDB node driver will automatically retry any queries for up to serverSelectionTimeoutMS (30 seconds by default). So your find() call will wait until mongoose.connect() succeeds up to a certain timeout. If it takes more than 30 seconds to connect, your find() will error out