From b72579e6e89be50c2cce9a715c360bd61d383281 Mon Sep 17 00:00:00 2001 From: Matin Gathani Date: Sun, 29 Mar 2026 18:04:52 -0700 Subject: [PATCH] fix(webhook): decode request body to string to avoid Buffer in Deno The Stripe SDK internally calls Buffer.isBuffer() when processing the webhook payload. Buffer is a Node.js global that does not exist in the Deno edge function runtime, which causes a ReferenceError. Decoding the raw ArrayBuffer to a UTF-8 string before passing it to processWebhook avoids the Buffer check entirely, since the SDK only performs the Buffer-specific code path for Buffer instances. Closes #170 --- .../src/supabase/edge-functions/stripe-webhook.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/sync-engine/src/supabase/edge-functions/stripe-webhook.ts b/packages/sync-engine/src/supabase/edge-functions/stripe-webhook.ts index abae828de..ff5dc2a14 100644 --- a/packages/sync-engine/src/supabase/edge-functions/stripe-webhook.ts +++ b/packages/sync-engine/src/supabase/edge-functions/stripe-webhook.ts @@ -26,8 +26,9 @@ Deno.serve(async (req) => { }) try { - const rawBody = new Uint8Array(await req.arrayBuffer()) - await stripeSync.webhook.processWebhook(rawBody, sig) + const rawBody = await req.arrayBuffer() + const bodyString = new TextDecoder().decode(rawBody) + await stripeSync.webhook.processWebhook(bodyString, sig) return new Response(JSON.stringify({ received: true }), { status: 200, headers: { 'Content-Type': 'application/json' },