Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryRunnerAlreadyReleasedError after runOnTransactionRollback #80

Open
herenickname opened this issue Jan 5, 2021 · 4 comments
Open

Comments

@herenickname
Copy link

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.

@cassinaooo
Copy link

Hi @ekifox, can you provide a minimal sample repo?

@odavid
Copy link
Owner

odavid commented Jan 21, 2021

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

@herenickname
Copy link
Author

@odavid so, how can I can solve my case? I need to save information to database when the all transaction has failed.

@odavid
Copy link
Owner

odavid commented Jan 21, 2021

@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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants