thrownewError('Transaction cannot be rolled back because it never started');
thrownewError('Transaction cannot be rolled back because it never started');
}
}
this._clearCls();
try{
try{
returnawaitthis
returnawaitthis
.sequelize
.sequelize
.getQueryInterface()
.getQueryInterface()
.rollbackTransaction(this,this.options);
.rollbackTransaction(this,this.options);
}finally{
}finally{
if(!this.parent){
this.cleanup();
this.cleanup();
}
}
}
}
}
/**
* Called to acquire a connection to use and set the correct options on the connection.
* We should ensure all of the environment that's set up is cleaned up in `cleanup()` below.
*
* @param {boolean} useCLS Defaults to true: Use CLS (Continuation Local Storage) with Sequelize. With CLS, all queries within the transaction callback will automatically receive the transaction object.
* @returns {Promise}
*/
asyncprepareEnvironment(useCLS){
asyncprepareEnvironment(useCLS){
letconnectionPromise;
letconnectionPromise;
...
@@ -162,6 +161,11 @@ class Transaction {
...
@@ -162,6 +161,11 @@ class Transaction {
}
}
cleanup(){
cleanup(){
// Don't release the connection if there's a parent transaction or