Alex
Alex
PPrisma
Created by Alex on 7/15/2024 in #help-and-questions
Error.code not defined for Deadlock & 40P01 error
Hi there, My script sometimes breaks as I've encounter a deadlock error. The error is the following one:
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(PostgresError { code: "40P01", message: "deadlock detected", severity: "ERROR", detail: Some("Process 67866 waits for ShareLock on transaction 68522241; blocked by process 67868.\nProcess 67868 waits for ShareLock on transaction 68522239; blocked by process 67866."), column: None, hint: Some("See server log for query details.") }), transient: false })
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(PostgresError { code: "40P01", message: "deadlock detected", severity: "ERROR", detail: Some("Process 67866 waits for ShareLock on transaction 68522241; blocked by process 67868.\nProcess 67868 waits for ShareLock on transaction 68522239; blocked by process 67866."), column: None, hint: Some("See server log for query details.") }), transient: false })
Unfortunately this error (40P01) doesn't seem to be handled correctly. I mean it's defined as a PrismaClientUnknownRequestError and so I can't get any error.code I can use in a try / catch block to handle it properly. When doing a console.log(error) I get the above text so the only way to handle the error is to use error.includes('deadlock detected'); which isn't a proper solution. Even the documentation doesn't mention this error : https://www.prisma.io/docs/orm/reference/error-reference#error-codes Any idea about this? Thanks for your time!
2 replies