Fixing Mongoose Transaction Error

Job ID: 36232249

Budget: $10 – $30 USD

I'm looking for someone that can help fixing transaction error bug with mongoose

Explanation:
I'm trying to do some atomic operations using mongoose transactions.
the transaction fails giving the next error

"MongoServerError: Given transaction number X does not match any in-progress transactions. The active transaction number is X-1"


Failed attempts to solve the problem:
1- close the connection after the logic finishes (as we may have consecutive middlewares that needs atomic operations)
2- retry opening a new transaction multiple times upon failure