typeorm-transactional-cls-hooked
typeorm-transactional-cls-hooked copied to clipboard
QueryRunnerAlreadyReleasedError after runOnTransactionRollback
I have a @Transactional()
function with runOnTransactionRollback(() => this.someRepository.save())
in it.
So, when the function caught error and rejects with rollback, the this.someRepository.save()
have called and then I receive the QueryRunnerAlreadyReleasedError error.
Hi @ekifox, can you provide a minimal sample repo?
Hi @ekifox / @cassinaooo - Sorry for the late response. I missed this one.
Basically, the runOnTransactionRollback()
and all the other Hooks, are informal only, and cannot be used to do database operations with the same repository.
I believe an external try/catch should be used instead
@odavid so, how can I can solve my case? I need to save information to database when the all transaction has failed.
@ekifox - As I said, the solution for that is to use an external (in the Transactional context) to call the transactional method with a try/catch
block
In the catch block you can call the repository.save()