Node seems to crash when database server goes down #8

Open
KalAvroniev opened this Issue Sep 5, 2012 · 1 comment

2 participants

@KalAvroniev

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?

@DrBenton
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment