Node-DBI icon indicating copy to clipboard operation
Node-DBI copied to clipboard

Node seems to crash when database server goes down

Open KalAvroniev opened this issue 13 years ago • 1 comments

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.

  1. I stopped the mysql server and start the node app. - I get this error: { [Error: connect ECONNREFUSED] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect' }
  2. I start the mysql server and the app reconnects to it.
  3. 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?

KalAvroniev avatar Sep 05 '12 05:09 KalAvroniev

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... :-)

olivierphi avatar Sep 16 '12 10:09 olivierphi