Closed gajus closed 9 years ago
I feel the other solution in that stack overflow thread is far cleaner. The one you suggested just feels like a hack.
Because promise-mysql handles the connection itself and doesn't expose the actual connection, I could easily handle it internally with the other solution.
Added in 84c7ed9fcc60a81cbc7fd3bdd6e1e4a87a1fcbe9
The nature of the promise API makes it impossible to use connection pool. There needs to be a way to keep the connection up for a continuously running service.
promise-mysql
wrapper does expose connection error handling (e.g.connection.on('error', fn)
) that would normally be used to restore a dead connection.I have proposed a (dirty) workaround for this on stack overflow, that involves making a simple query at a regular interval to keep the connection up:
It almost feels that this should be part of
promise-mysql
.