Connection.transaction: Model instance state is not reverted after a failed transaction #8380
Labels
enhancement
This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Milestone
Do you want to request a feature or report a bug?
Something in between, probably more of a feature since it could be a large task.
What is the current behavior?
Model instance state is not reverted after a failed transaction and trying to save it after the transaction is aborted will result in a VersionError.
If the current behavior is a bug, please provide the steps to reproduce.
This is a pseudo example, not a real-world scenario. It's enough to reproduce the problem.
If after the transaction fails I reset user.name and user.__v to their initial values, the catch statement executes correctly.
What is the expected behavior?
Model instance data is reverted to what it was initially if the related transaction fails.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
I use mongoose 5.6.9 and for the time being I'd like to avoid the update to 5.7.12 'cause my env is quite unstable. I checked the release notes and open issues and have not noticed this behavour mentioned anywhere.
The text was updated successfully, but these errors were encountered: