Skip to content
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

Recognize fatal mysql2 connection errors #2175

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/dialects/mysql2/index.js
Expand Up @@ -29,8 +29,8 @@ assign(Client_MySQL2.prototype, {
return require('mysql2')
},

validateConnection() {
return true
validateConnection(connection) {
return !connection._fatalError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that ._fatalError attribute part of public API of mysql2 driver?

},

// Get a raw connection, called by the `pool` whenever a new
Expand All @@ -50,6 +50,10 @@ assign(Client_MySQL2.prototype, {
})
},

destroyRawConnection(connection) {
if (!connection._fatalError) return Client_MySQL.prototype.destroyRawConnection(connection)
},

processResponse(obj, runner) {
const { response } = obj
const { method } = obj
Expand Down