Question
Answer
The issue causing the error might be related to a bug in Prisma. It is advised to create a new issue on Github and include details of the error. Increasing timeouts might help in some cases, but it is not a guaranteed solution. To gracefully recover from this error, it is possible to use `prisma.c.$disconnect()` in a catch block, which would close all existing connections with the database and allow the client to automatically connect to the database by opening a new connection on the subsequent request. In order to get more information about what is going on, it is recommended to use the recently shipped Prisma metrics, which can provide information about how many active connections Prisma holds and other relevant details. If the error only occurs when the database is located far away, then increasing timeouts might be the only solution as there isn't a global configuration to increase timeouts for transactions. It is important to note that this error can be intermittent and may not occur consistently.
Mischa
06/05/2022, 7:35 PM{
maxWait: 20000, // default: 2000
timeout: 60000, // default: 5000
}
{"is_panic":false,"message":"Transaction API error: Transaction already closed: Transaction is no longer valid. Last state: 'Expired'.","meta":{"error":"Transaction already closed: Transaction is no longer valid. Last state: 'Expired'."},"error_code":"P2028","clientVersion":"3.14.0"}
Nurul
06/06/2022, 7:13 AMMischa
06/06/2022, 8:14 PMMischa
06/07/2022, 8:13 PMNurul
06/08/2022, 4:48 PMMischa
06/08/2022, 5:56 PMMischa
06/08/2022, 5:59 PMMischa
06/08/2022, 7:12 PMMischa
06/08/2022, 7:12 PMprisma.c.$disconnect()
in a catch() block but I have no idea if that's correct or usefulNurul
06/09/2022, 10:22 AMMischa
06/10/2022, 1:05 AMMischa
06/10/2022, 1:05 AMMischa
06/10/2022, 1:05 AMIlia Kostichenko
06/14/2022, 9:38 AMMischa
06/15/2022, 4:06 PMNurul
06/21/2022, 1:27 PMIlia Kostichenko
06/21/2022, 1:32 PM