agco / harvesterjs

Create JSONAPI-compliant APIs over a Node.js + MongoDB stack in an easy, boilerplate-free manner
http://agco.github.io/harvesterjs/
MIT License
68 stars 13 forks source link

mongodb connection loss crashes the app #133

Closed kristofsajdak closed 8 years ago

kristofsajdak commented 9 years ago

when a harvesterjs app is running, and the connection to Mongodb is lost at some point, it will crash the application with the following error message :

events.js:72 throw er; // Unhandled 'error' event ^ Error: failed to connect to [192.168.59.103:27017] at null. (/Users/CDBKRS/projects/harvesterjs/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:555:74) at emit (events.js:106:17) at null. (/Users/CDBKRS/projects/harvesterjs/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:156:15) at emit (events.js:98:17) at Socket. (/Users/CDBKRS/projects/harvesterjs/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:534:10) at Socket.emit (events.js:95:17) at net.js:440:14 at process._tickCallback (node.js:419:1

kristofsajdak commented 9 years ago

Apparently this is a Mongoose level issue, the version which we are using doesn't come with a default resilience mechanism.

Applying what I found as an accepted answer on Stackoverflow : http://stackoverflow.com/questions/10873199/how-to-handle-mongoose-db-connection-interruptions

It feels like a hack, but should do for now. Did some tests where I stopped and started Mongodb, and it does reconnect automatically.

kristofsajdak commented 9 years ago

https://github.com/agco/harvesterjs/pull/134

mavdi commented 8 years ago

This has been fixed since our upgrade to v4.2