kcbanner/connect-mongo — Issue #14: Error not handled when MongoDB is not available
Author: andyuk
Created: 2011-10-25 10:44:23+00:00
State: open

When MongoDB goes down, I wouldn't expect connect-mongo to just crash. I get the following error response on the webpage:

Error: notConnected
at [object Object].executeCommand (/Users/me/myapp/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js:779:25)
at Collection.findOne (/Users/me/myapp/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/collection.js:773:11)
at /Users/me/myapp/node_modules/connect-mongo/lib/connect-mongo.js:143:16
at MongoStore._get_collection (/Users/me/myapp/node_modules/connect-mongo/lib/connect-mongo.js:92:19)
at MongoStore.get (/Users/me/myapp/node_modules/connect-mongo/lib/connect-mongo.js:142:8)
at Object.session [as handle] (/Users/me/myapp/node_modules/express/node_modules/connect/lib/middleware/session.js:319:11)
at next (/Users/me/myapp/node_modules/express/node_modules/connect/lib/http.js:201:15)
at /Users/me/myapp/node_modules/express/node_modules/connect/lib/middleware/static.js:148:11

Can we handle this better so my app can at least do something when session support isn't available?