olivierwilkinson / prisma-extension-soft-delete

Prisma extension for adding soft delete to Prisma models, even when using nested queries
Apache License 2.0
82 stars 11 forks source link

Transactions Failing When Utilizing Extension #24

Open arimgibson opened 1 month ago

arimgibson commented 1 month ago

When using the soft delete client to try and perform a transaction, the following error is thrown:

error: All elements of the array need to be Prisma Client promises. Hint: Please make sure you are not awaiting the Prisma client calls you intended to pass in the $transaction function.

The same transaction will run successfully when not utilizing the extension. Workaround: utilize a normal Prisma client for transactions

Can come back later this week to provide a reproduction; don't have time right this second and thought I'd throw this out there in case this is something we're already aware of. Couldn't find in other bug reports

rpaterson commented 3 weeks ago

The error appears on sequential (array) style calls to $transaction([ ... ]), but not on interactive style calls to $transaction(async (prisma) => { ... })

rpaterson commented 3 weeks ago

So as a workaround it's easy to convert from "sequential" to "interactive" style

rpaterson commented 3 weeks ago

Actually looking at the code I think "interactive" style transactions don't throw this error, but the queries are not actually run inside the transaction, which is even worse!

baojr commented 2 weeks ago

I just found the same problem @rpaterson described in my project. After installing this extension, previously working code is now unable to read data written within the same transaction, which violates the isolation properties of SQL transactions.

vinnymac commented 2 days ago

I ran into this issue today as well. Although in my case, this appears to also happen if I configure additional extensions. If prisma-extension-soft-delete is the only extension configured, transactions work just fine 🤷🏼‍♂️.

In my case, both removing prisma-extension-soft-delete, or making it the only extension resolves the issue.

arimgibson commented 2 days ago

I ran into this issue today as well. Although in my case, this appears to also happen if I configure additional extensions. If prisma-extension-soft-delete is the only extension configured, transactions work just fine 🤷🏼‍♂️.

In my case, both removing prisma-extension-soft-delete, or making it the only extension resolves the issue.

Interesting observation; haven't seen the same here! This is the only one we're using and still having issues. Will try to get around to that reproducible example this weekend; keeps slipping my mind

For others with the same, please +1 (thumbs up) this comment instead of starting a long chain of just "same" -- keeps things cleaner. Thank you :pray: