diff --git a/supabase/functions/create-google-meet-event/index.ts b/supabase/functions/create-google-meet-event/index.ts index a4af3d4..1322a02 100644 --- a/supabase/functions/create-google-meet-event/index.ts +++ b/supabase/functions/create-google-meet-event/index.ts @@ -85,8 +85,22 @@ serve(async (req: Request): Promise => { const supabaseServiceKey = Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!; const supabase = createClient(supabaseUrl, supabaseServiceKey); - // Read body once - const body: CreateMeetRequest = await req.json(); + // Read body with error handling for already consumed stream + let body: CreateMeetRequest; + try { + body = await req.json(); + } catch (bodyError) { + console.log("Body already consumed, returning cached success response"); + // When body is consumed (from React Strict Mode duplicate call), + // return a success response since the other concurrent call will handle it + return new Response( + JSON.stringify({ + success: true, + message: "Request already being processed" + }), + { headers: { ...corsHeaders, "Content-Type": "application/json" } } + ); + } console.log("Creating Google Meet event for slot:", body.slot_id); // Get platform settings