database: Fix event emitter warning

the connection object gets reused after release. this means that we keep
attaching the 'error' event and not unlistening.

--trace-warnings can be added to box.service to get the stack trace
This commit is contained in:
Girish Ramakrishnan
2020-07-02 11:59:45 -07:00
parent 493f1505f0
commit 70743bd285

View File

@@ -145,7 +145,9 @@ function rollback(connection, transactionError, callback) {
connection.rollback(function (error) {
if (error) debug('rollback: error when rolling back', error);
connection.removeAllListeners('error');
connection.release();
callback(transactionError);
});
}
@@ -169,7 +171,9 @@ function transaction(queries, callback) {
connection.commit(function (error) {
if (error) return rollback(connection, error, callback);
connection.removeAllListeners('error');
connection.release();
callback(null, results);
});
});