knex: Leaked exception if database crashes. (MySQL server has gone away)
Environment
Knex version:0.14.2 Database + version: mariaDb v10.2 OS: Ubuntu Node: v9.3.0
My connection:
const Knex = require('knex')({
client: 'mariasql',
connection: {
host: config.host,
user: config.user,
password: config.password,
db: config.database,
charset: 'utf8',
pool: { min: 2, max: 10 },
acquireConnectionTimeout: 30000
}
});
After period of time my node app crash with error:
events.js:136
throw er; // Unhandled 'error' event
^
Error: MySQL server has gone away
Please help me resolve this issue. Thanks all!
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (11 by maintainers)
@wubzz I thought the default pool setting
testOnBorrow: trueshould take care of that case that dead connection is not returned from pool (if knex get the event of closed connection from the driver). It would be interesting to see if setting theevictionRunIntervalMillismakes a difference 👍 One more thing that could happen is that connection is fetched from pool for example for transaction and never returned. In that case dead connection probably would throw the error mentioned in OP (I don’t believe that this is the problem here though).