From 998435196c114d1a62e8b43cb7775f0cd4a0d931 Mon Sep 17 00:00:00 2001 From: Aleksei Rozhnov Date: Thu, 30 Jan 2025 11:36:04 +0000 Subject: [PATCH] fix racecondition with 2 stripe customers for 1 user --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ae4a882..d6282f3 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,11 @@ export async function GET(req: Request) { email: user.email, metadata: { userId: user.id, // DO NOT FORGET THIS - }, + } + }, { + // prevent race conditions of creating 2 customers in stripe for on user + // https://github.com/stripe/stripe-node/issues/476#issuecomment-402541143 + idempotencyKey: user.id }); // Store the relation between userId and stripeCustomerId in your KV