Transaction breaking all following queries when using "findOneAndUpdate". #15197
Labels
can't reproduce
Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.
Prerequisites
Mongoose version
^8.9.5
Node.js version
v22.11.0
MongoDB server version
8.0.4
Typescript version (if applicable)
^5.7.2
Description
Hi,
I have made myself a transaction function for handling multiple queries at once with my backend API. My issue is, after the function runs once, it breaks all following queries made with mongoose. I am not sure why and all I can think is that it is an issue out of my hands.
I have found that if I change the second query within the transaction function from "findOneAndUpdate" to "updateOne", everything works as it should. I would rather use findOneAndUpdate, though.
This is the error I receive when it errors:
Thanks for any help.
Steps to Reproduce
The function:
Here is how I am using the function (within the API endpoint):
How to reproduce:
Expected Behavior
I expect the same result as the first API request.
"message": "Successfully ..."
The text was updated successfully, but these errors were encountered: