New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transaction with bad input should rollback (when using middleware) #6705
Comments
Yeah most likely, just put an example on top of my head but I will try to reproduce. I think it my be due to a children |
Ok I dig out the issue, it happens when there is a middleware present.
This is my middleware: prisma.$use(async (params, next) => {
try {
const result = await next(params);
return result;
} catch (err) {
console.log(err);
throw err;
}
}); |
Note: The rollback is ensured by controlling a race condition. In |
So in link with what I mentioned above, the current transaction implementation relies on failure immediateness to rollback. For this reason, since middlewares are asynchronous by design and under the hood, we cannot rollback. Doing The obvious solution now is that we implement #1844 |
I mean in my case one of the query fails the validation and is not even sent through to the query engine. Could we at least get that working? |
If we "fix" things so that it can fail/stop on |
Depends on #1844 |
Bug description
If one query in the transaction fails the input validation, the transaction doesn't rollback and the other queries proceed normally.
Error:
How to reproduce
Consider the following schema:
Run the following code:
There should be a user in the database as the transaction is not rollback.
Expected behavior
The transaction should be rollback.
Environment & setup
The text was updated successfully, but these errors were encountered: