chore: clear listener after transaction commited (#4879)

This commit is contained in:
ChengLei Shao 2024-07-14 22:28:23 +08:00 committed by GitHub
parent 954e9304d9
commit 7542f12445
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -27,6 +27,17 @@ export function transactionWrapperBuilder(transactionGenerator) {
newTransaction = true;
}
transaction.afterCommit(() => {
if (transaction.eventCleanupBinded) {
return;
}
transaction.eventCleanupBinded = true;
if (this.database) {
this.database.removeAllListeners(`transactionRollback:${transaction.id}`);
}
});
// 需要将 newTransaction 注入到被装饰函数参数内
if (newTransaction) {
try {