node-mysql2: ETIMEDOUT error since v1.1.1
I have a local mysql database that I use for testing and v1.1.1 introduced some sort of bug or configuration change that is causing the error:
{ Error: connect ETIMEDOUT
at Connection._handleTimeoutError (/home/myuser/code/itemdrop/node_modules/mysql2/lib/connection.js:166:13)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
errorno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
fatal: true }
Confirmed this does not happen with v1.1.0 by downgrading my project back to that version. I’m using knexjs v0.12.2 to connect with the connection object of:
var knex = require('knex')({
client: 'mysql2',
connection: {
host: 'localhost',
user: '***',
password: '***',
database: 'mydb'
}
});
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 4
- Comments: 32 (8 by maintainers)
@chunkiat82 Not sure if this relates to your case but here goes https://github.com/sequelize/sequelize/blob/2429146758e444716fe6f29897a787dd2dc37d48/lib/dialects/mysql/connection-manager.js#L85-L89
I observed connection can throw error two times, so you probably need to take care of that. Even if first error is protocol lost or something due to network error, that connection will throw another timeout error.
We need to cancel timeout handler when error event is observed, IIRC we only do that for successful connection case.
Running into this as well on Node 6.9.1, Knex 0.10 and mysql2 1.1.0 through 1.1.2 (we’ve been testing various versions). After about 12-13 hours of the process running these errors start.
We haven‘t tested the official mysql client yet, but we were previously using mariasql with Knex and weren’t experiencing this problem – it popped up upon switching to mysql2.
@sidorares I haven’t tried that but I noticed that rolling back to nodejs v6.3.1 fixes this bug for me.