medz / prisma-dart

Prisma Client Dart is an auto-generated type-safe ORM. It uses Prisma Engine as the data access layer and is as consistent as possible with the Prisma Client JS/TS APIs.
https://prisma.pub
BSD 3-Clause "New" or "Revised" License
459 stars 31 forks source link

Transaction not working in v5 #413

Closed yamarkz closed 2 months ago

yamarkz commented 3 months ago

Thank you for your continuous maintenance of the package.

I am using prisma-dart in a commercial product and have been operating with version 4 so far. Recently, I attempted to upgrade to version 5, but I noticed that the behavior around transactions has changed, causing it to no longer function correctly.

Upon reviewing the code, it seems that the implementation has changed fundamentally. I am utilizing the "Manual Transactions" approach as described in the documentation. Do you have any insights or ideas about what might be causing this?

I am encountering the following error message:

  ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  │ PrismaClientKnownRequestError: P2028 Transaction API error: Transaction not found. Transaction ID is invalid, refers to an old closed transaction Prisma doesn't have information about anymore, or was obtained before disconnecting.
  ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
  │ #0   _extension#0.throwPrismaKnowError (package:orm/src/engines/binary_engine.dart:510:7)
  │ #1   _extension#0.throwErrors (package:orm/src/engines/binary_engine.dart:491:24)
  │ #2   BinaryEngine.request (package:orm/src/engines/binary_engine.dart:77:44)
  │ #3   <asynchronous suspension>
  │ #4   ActionClient.unserialized.<anonymous closure> (package:orm/src/runtime/action_client.dart:17:34)
  ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
  │ 2024-08-14 12:49:51.160
  ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
  │ ⛔ PrismaClientKnownRequestError: P2028 Transaction API error: Transaction not found. Transaction ID is invalid, refers to an old closed transaction Prisma doesn't have information about anymore, or was obtained before disconnecting.
  └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
medz commented 3 months ago

@yamarkz It seems that the txid is not passed correctly after startTX. I will check it out when I have time.

PS: However, I may not be able to fix it quickly because I am busy recently. I am preparing for an interview and developing software for a great client.

In addition, I rarely use manual things, and I want to sort out the known issues of the current Prisma 5.18 version:

  1. The RAW protocol has changed, but I don’t have time to adapt it yet.
  2. As the question says, there may be potential problems.

If you are in a hurry, you can submit a PR for me, and I will quickly verify and release a new version.

For the current Prisma Dart v5 version, I recommend using the 5.17.* version of Prisma CLI, because there are destructive changes in the 5.18 version that I cannot adapt quickly for the time being.

yamarkz commented 3 months ago

Thank you for your comment. I'll try to verify this with different versions of prisma on my end. comment here if there is further information.

medz commented 2 months ago

@yamarkz I have successfully fixed it, please upgrade to version 5.0.6.

yamarkz commented 2 months ago

@medz Great job!