From abaee59965f9aeea8f50760900a1edf99d5d8828 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sun, 28 Sep 2025 00:17:17 +0000 Subject: [PATCH] Guard Supabase realtime channel usage to prevent runtime errors cgen-2bd999acc01d4c88aea6ab918f2ea3f9 --- client/lib/supabase-service.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/client/lib/supabase-service.ts b/client/lib/supabase-service.ts index 1195ace0..bc44e628 100644 --- a/client/lib/supabase-service.ts +++ b/client/lib/supabase-service.ts @@ -367,7 +367,11 @@ export const realtimeService = { userId: string, callback: (notification: any) => void, ) { - return supabase + const client: any = supabase as any; + if (!client || typeof client.channel !== "function") { + return { unsubscribe: () => {} } as any; + } + return client .channel(`notifications:${userId}`) .on( "postgres_changes", @@ -383,7 +387,11 @@ export const realtimeService = { }, subscribeToCommunityPosts(callback: (post: any) => void) { - return supabase + const client: any = supabase as any; + if (!client || typeof client.channel !== "function") { + return { unsubscribe: () => {} } as any; + } + return client .channel("community_posts") .on( "postgres_changes",