New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled Exception in connection.end()
for MySQL Dialect
#1691
Comments
Yikes, sorry about that.
Basically it's there just to clean up any listeners hanging around that aren't needed anymore since the connection shouldn't be accessible for any purpose once it's "destroyed" anyway. I think this would be the preferred solution: connection.end(err => {
err.__knex__disposed = err
}) or maybe even: destroyRawConnection(connection) {
connection.end(() => {
connection.removeAllListeners()
})
} so that any error handler still exists until after the connection is definitely ended. |
Just pushed a fix in 0.12.2, thanks for the report! |
There's an open issue on the mysql repo for ClearDB not responding the a Quit packet.
This affects knex when destroying an idle connection using
Client_MySQL.destroyRawConnection()
.The unhandled exception thrown by mysql on
connection.end()
was crashing my application and there is really no way to handle it as knex is currently setup.I would be willing to open a PR and fix the bug, but I'm not sure which strategy is most appropriate.
The easiest would be to remove the call to
removeAllListeners()
, according to the NodeJS docsThat said, I'm assuming there is a reason knex is calling this method? Maybe something to do with performance?
An alternative would be to pass in an error callback to `.end()', for example:
Let me know which approach would be best and I'll make the change and open a PR.
As a workaround, for anyone else experiencing issues with knex, heroku, mysql, and cleardb I've done the following and it works for now but is fairly ugly...
The text was updated successfully, but these errors were encountered: