Lukáš Stuchlík
03/16/2022, 9:14 AMawait prisma.$transaction(async (prisma) => {
for (const entity of changed) {
await prisma.entity.update({
where: ...
data: ...
})
}
if (deleted.length) {
// soft delete
await prisma.entity.updateMany({
where: ...,
data: {
deleted: true,
}
})
}
if (created.length) {
await prisma.entity.createMany({
data: created,
})
}
logResult(...)
})
The transaction itself works (it's used this way in many different entities and they pass alright), but in a few that seem to run much longer than other, I'm getting an exception: PrismaClientKnownRequestError: Transaction API error: Transaction already closed: Transaction is no longer valid. Last state: 'Expired'.
What can I do about it, or what causes it?Lukáš Stuchlík
03/16/2022, 12:06 PM$transaction()
has second parameter with options maxWait
and timeout
with timeout
having default 5s
... Upping the timeout worked 👍