From 8afa0bbad28898f7dec04ea1ae1fbebef9d4e1b2 Mon Sep 17 00:00:00 2001 From: pac7 <47831526-pac7@users.noreply.replit.com> Date: Tue, 7 Oct 2025 15:46:16 +0000 Subject: [PATCH] Improve reliability when updating data subscriptions Add try-catch block to handle potential errors during Supabase channel removal in `useEntityVersions.ts`. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 8e00d8b1-e8de-4f48-99ca-dbba7279e1a6 Replit-Commit-Checkpoint-Type: intermediate_checkpoint --- src/hooks/useEntityVersions.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hooks/useEntityVersions.ts b/src/hooks/useEntityVersions.ts index d13d85a1..e94727e7 100644 --- a/src/hooks/useEntityVersions.ts +++ b/src/hooks/useEntityVersions.ts @@ -197,8 +197,13 @@ export function useEntityVersions(entityType: string, entityId: string) { // Clean up existing channel if any if (channelRef.current) { - supabase.removeChannel(channelRef.current); - channelRef.current = null; + try { + supabase.removeChannel(channelRef.current); + } catch (error) { + console.error('Error removing previous channel:', error); + } finally { + channelRef.current = null; + } } // Create new channel