diff --git a/src/database.js b/src/database.js index d80cae27c..b4b669cec 100644 --- a/src/database.js +++ b/src/database.js @@ -57,6 +57,8 @@ async function initialize() { }); gConnectionPool.on('connection', function (connection) { + debug('connected'); + // connection objects are re-used. so we have to attach to the event here (once) to prevent crash // note the pool also has an 'acquire' event but that is called whenever we do a getConnection() connection.on('error', (error) => debug(`Connection ${connection.threadId} error: ${error.message} ${error.code}`)); @@ -74,6 +76,7 @@ async function uninitialize() { gConnectionPool.end(); gConnectionPool = null; + debug('connection closed'); } async function clear() { @@ -86,7 +89,7 @@ async function clear() { } async function query() { - assert.notStrictEqual(gConnectionPool, null); + assert.notStrictEqual(gConnectionPool, null, 'Database connection is already closed'); return new Promise((resolve, reject) => { const args = Array.prototype.slice.call(arguments);