Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update with-prisma-retry.ts

Kiran K27d0f5b65a3b
diff --git a/apps/web/lib/api/utils/with-prisma-retry.ts b/apps/web/lib/api/utils/with-prisma-retry.ts
index 9f18f7336c..52bf81fbf4 100644
--- a/apps/web/lib/api/utils/with-prisma-retry.ts
+++ b/apps/web/lib/api/utils/with-prisma-retry.ts
@@ -6,12 +6,16 @@ const DEFAULT_CONFIG = {
exponentialBackoff: true,
};
-const NON_RETRIABLE_ERROR_CODES = new Set([
- "P2000", // Value too long for column
- "P2001", // Record not found for where condition
- "P2002", // Unique constraint violation
- "P2003", // Foreign key constraint violation
- "P2025", // Record not found for operation
+const RETRIABLE_ERROR_CODES = new Set([
+ "P1001",
+ "P1002",
+ "P1003",
+ "P1008",
+ "P1011",
+ "P1017",
+ "P2024",
+ "P2028",
+ "P2037",
]);
// Helper function for retrying operations
@@ -28,8 +32,7 @@ export async function withPrismaRetry<T>(
lastError = error as Error;
if (error instanceof Prisma.PrismaClientKnownRequestError) {
- // Only exclude permanent errors, not connection issues
- if (NON_RETRIABLE_ERROR_CODES.has(error.code)) {
+ if (!RETRIABLE_ERROR_CODES.has(error.code)) {
throw error;
}
}