Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

perf(webhooks): reduce Stripe user lookup retry count and delay

Richie McIlroy84f1b2b09ab1
diff --git a/apps/web/app/api/webhooks/stripe/route.ts b/apps/web/app/api/webhooks/stripe/route.ts
index b191ff893..e3323fa11 100644
--- a/apps/web/app/api/webhooks/stripe/route.ts
+++ b/apps/web/app/api/webhooks/stripe/route.ts
@@ -49,7 +49,7 @@ async function createGuestUser(
async function findUserWithRetry(
email: string,
userId?: User.UserId,
- maxRetries = 5,
+ maxRetries = 2,
): Promise<typeof users.$inferSelect | null> {
for (let i = 0; i < maxRetries; i++) {
console.log(`[Attempt ${i + 1}/${maxRetries}] Looking for user:`, {
@@ -91,7 +91,7 @@ async function findUserWithRetry(
}
if (i < maxRetries - 1) {
- const delay = 2 ** i * 3000;
+ const delay = 2 ** i * 500;
console.log(
`No user found on attempt ${
i + 1
@@ -102,7 +102,7 @@ async function findUserWithRetry(
} catch (error) {
console.error(`Error during attempt ${i + 1}:`, error);
if (i < maxRetries - 1) {
- const delay = 2 ** i * 3000;
+ const delay = 2 ** i * 500;
await new Promise((resolve) => setTimeout(resolve, delay));
}
}