Grokking ExpressJS
Vote

0% completed

​

Connecting Express.js with MongoDB using Mongoose

A Mongoose query sent before the database connection is open does not fail at once. Mongoose holds it in a queue and waits up to 10 seconds for the connection, and only then does it throw an error that ends with buffering timed out after 10000ms. That behavior is convenient in a script, but in a web server it means a request can hang for 10 seconds when the database is down. The safe pattern, which this lesson builds, is to open the connection first and start accepting HTTP requests only after it succeeds.

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content