Node-DBI
Node-DBI copied to clipboard
Node seems to crash when database server goes down
I've implemented your module and was testing it to see how well it works. I found an issue with it when the database server dies the whole node application crashes because there is no event listener on error.
So this is what I did: I have a node server that checks the database connection every 10 seconds.
- I stopped the mysql server and start the node app. - I get this error: { [Error: connect ECONNREFUSED] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect' }
- I start the mysql server and the app reconnects to it.
- I stop the mysql server and after a while, 2-5 seconds, I get this error: events.js:66 throw arguments[1]; // Unhandled 'error' event ^ Error: connect ECONNREFUSED at errnoException (net.js:768:11) at Object.afterConnect as oncomplete
Can you please fix this because I do not want my node app to die every time the database crashes?
This needs some work on each Adapter, and not all of them are documented about error handling (PostgreSQL for example : https://github.com/brianc/node-postgres/wiki/Error-handling ) I will try to fix this, but since I don't have much free time these days I may need some help. Pull Requests would be appreciated... :-)