I have a problem with my Mongo database.
I am using Mongoose Transactions to save multiple documents to my database and they are all saved in the end and the transaction is commited, but I still get a MongoError and my app crashes:
MongoError: Attempted illegal state transition from [TRANSACTION_COMMITTED] to [TRANSACTION_ABORTED]
For me the problem was that I was not waiting for transaction commit. So I change this:
session.commitTransaction();
session.endSession();
Into:
await session.commitTransaction();
session.endSession();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With