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
This commit is contained in:
pac7
2025-10-07 15:46:16 +00:00
parent f97bb91b11
commit 8afa0bbad2

View File

@@ -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