diff --git a/packages/backend/src/misc/is-duplicate-key-value-error.ts b/packages/backend/src/misc/is-duplicate-key-value-error.ts index 18d22bb77..670277fe1 100644 --- a/packages/backend/src/misc/is-duplicate-key-value-error.ts +++ b/packages/backend/src/misc/is-duplicate-key-value-error.ts @@ -1,3 +1,4 @@ export function isDuplicateKeyValueError(e: unknown | Error): boolean { - return (e as Error).message?.startsWith("duplicate key value"); + const nodeError = e as NodeJS.ErrnoException; + return nodeError.code === "23505"; }