You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When wrapping the Prisma client with withPgAdapter, the rollback mechanism for interactive transactions fails. Specifically, if an error is thrown within a transaction, the changes are not reverted as expected.
Setup:
• Initialize a project using Prisma Client version 5.22..
• Wrap your Prisma client instance with withPgAdapter (using version 0.8. or 0.7.*).
Example:
import { PrismaClient } from '@prisma/client';
import { withPgAdapter } from 'your-adapter-package';
const prisma = withPgAdapter(new PrismaClient());
Create a Transaction:
• Start an interactive transaction using prisma.$transaction() and perform one or more database operations.
Trigger Rollback:
• Within the transaction block, deliberately throw an error to trigger a rollback.
Example:
await prisma.$transaction(async (prismaTx) => {
await prismaTx.user.create({ data: { name: 'Test' } });
// Simulate an error to force rollback
throw new Error('Intentional failure to trigger rollback');
});
Observation:
• Instead of rolling back the transaction, the changes made prior to the error persist (or the rollback mechanism is bypassed).
Expected Behavior
When an error is thrown within an interactive transaction, the entire transaction should be rolled back, ensuring that no partial changes remain in the database.
Observed Behavior
With the Prisma client wrapped using withPgAdapter, the rollback does not occur. This means that even after an error is thrown, the operations executed before the error are not reverted.
Additional Context
• This issue consistently appears with the mentioned versions of Prisma Client and the adapter.
• The problem seems specific to scenarios where the Prisma client is wrapped with withPgAdapter.
• Any insights into how the adapter might interfere with the transaction rollback process would be appreciated.
Request
Please advise if further details, such as a minimal reproduction repository or additional logs, would help diagnose the issue. Thank you for your time and efforts in looking into this problem.
The text was updated successfully, but these errors were encountered:
Hello Bemi-Team,
Summary
When wrapping the Prisma client with withPgAdapter, the rollback mechanism for interactive transactions fails. Specifically, if an error is thrown within a transaction, the changes are not reverted as expected.
Environment
• Prisma Client Version: 5.22.*
• withPgAdapter Version: 0.8.* (also reproduced with 0.7.*)
• PostgreSQL
Steps to Reproduce
• Initialize a project using Prisma Client version 5.22..
• Wrap your Prisma client instance with withPgAdapter (using version 0.8. or 0.7.*).
Example:
• Start an interactive transaction using prisma.$transaction() and perform one or more database operations.
• Within the transaction block, deliberately throw an error to trigger a rollback.
Example:
• Instead of rolling back the transaction, the changes made prior to the error persist (or the rollback mechanism is bypassed).
Expected Behavior
When an error is thrown within an interactive transaction, the entire transaction should be rolled back, ensuring that no partial changes remain in the database.
Observed Behavior
With the Prisma client wrapped using withPgAdapter, the rollback does not occur. This means that even after an error is thrown, the operations executed before the error are not reverted.
Additional Context
• This issue consistently appears with the mentioned versions of Prisma Client and the adapter.
• The problem seems specific to scenarios where the Prisma client is wrapped with withPgAdapter.
• Any insights into how the adapter might interfere with the transaction rollback process would be appreciated.
Request
Please advise if further details, such as a minimal reproduction repository or additional logs, would help diagnose the issue. Thank you for your time and efforts in looking into this problem.
The text was updated successfully, but these errors were encountered: