You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using typeorm-transactional-cls-hooked in my NestJS application to manage transactions. I have a method decorated with @transactional() where I'm trying to delete a non-existing record to force a transaction rollback. However, even though I see a log message indicating that the transaction has been rolled back, the changes made earlier in the transaction are not being rolled back in the database.
Expected behavior I expect that when an error is thrown in a transaction, all changes made in that transaction are rolled back.
To Reproduce Here's a simplified version of my code:
@Transactional()asyncupdateTask({ id }: Task): Promise<TaskEntity>{// ... some code to update a task ...const taskSaved =awaitthis.taskRepository.save(updatedTask);runOnTransactionRollback(()=>{this.logger.log('Transaction rolled back');});// delete a task that does not exist to test transaction rollbackawaitthis.taskRepository.delete({id: 'non-existing-id'});returntaskSaved;}
In this code, I'm updating a task and then trying to delete a non-existing task. When the delete operation doesn't find a task to delete, it should throw an error and the transaction should roll back, undoing the previous save operation. However, the save operation is not being rolled back.
I'm using typeorm-transactional-cls-hooked in my NestJS application to manage transactions. I have a method decorated with @transactional() where I'm trying to delete a non-existing record to force a transaction rollback. However, even though I see a log message indicating that the transaction has been rolled back, the changes made earlier in the transaction are not being rolled back in the database.
Expected behavior I expect that when an error is thrown in a transaction, all changes made in that transaction are rolled back.
To Reproduce Here's a simplified version of my code:
In this code, I'm updating a task and then trying to delete a non-existing task. When the delete operation doesn't find a task to delete, it should throw an error and the transaction should roll back, undoing the previous save operation. However, the save operation is not being rolled back.
Environment:
Node.js version: (e.g., 14.15.1)
NestJS version: (e.g., 7.6.15)
typeorm-transactional-cls-hooked version: (e.g., 1.0.0)
Database and version: (e.g., PostgreSQL 13.3)
The text was updated successfully, but these errors were encountered: