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