I tried it, and I think, the plugin should use default knex methods to close the connection. Right now calling knex.destroy() does nothing, and the connection hangs.
I've come up with this code to close the connection:
const mysql = require('serverless-mysql')({ config });
const knexServerlessMysql = require('knex-serverless-mysql');
const knexInstance = Knex({
mysql,
client: knexServerlessMysql,
} as any);
// ...
const originalDestroy = (knexInstance as any).context.destroy;
(knexInstance as any).context.destroy = async () => {
if (knexInstance) {
await originalDestroy.apply(knexInstance);
}
if (mysql) {
await mysql.end();
mysql.quit();
}
};
Is there any way this could be integrated within knex-serverless-mysql?
Firstly, thanks a lot for this plugin!
I tried it, and I think, the plugin should use default knex methods to close the connection. Right now calling
knex.destroy()
does nothing, and the connection hangs.I've come up with this code to close the connection:
Is there any way this could be integrated within
knex-serverless-mysql
?