From 0b178d45baeddf9173a754f9ae46584fe6e8e811 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 17 Apr 2026 13:24:57 -0500 Subject: [PATCH] fix: unsubscribe from pubsub topics on LiveView terminate; catch-all handle_info in ConnectionManager --- lib/aprsme/cluster/connection_manager.ex | 3 +++ lib/aprsme_web/live/map_live/index.ex | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lib/aprsme/cluster/connection_manager.ex b/lib/aprsme/cluster/connection_manager.ex index 12771d5..f142fdc 100644 --- a/lib/aprsme/cluster/connection_manager.ex +++ b/lib/aprsme/cluster/connection_manager.ex @@ -56,6 +56,9 @@ defmodule Aprsme.Cluster.ConnectionManager do end end + @impl true + def handle_info(_msg, state), do: {:noreply, state} + @impl true def terminate(_reason, _state) do Phoenix.PubSub.unsubscribe(Aprsme.PubSub, "cluster:leadership") diff --git a/lib/aprsme_web/live/map_live/index.ex b/lib/aprsme_web/live/map_live/index.ex index 148bbad..9c19ed5 100644 --- a/lib/aprsme_web/live/map_live/index.ex +++ b/lib/aprsme_web/live/map_live/index.ex @@ -1878,6 +1878,10 @@ defmodule AprsmeWeb.MapLive.Index do # Unsubscribe from StreamingPacketsPubSub Aprsme.StreamingPacketsPubSub.unsubscribe(self()) + # Unsubscribe from Endpoint/PubSub topics subscribed in mount + Endpoint.unsubscribe("aprs_messages") + Phoenix.PubSub.unsubscribe(Aprsme.PubSub, "postgres:aprsme_packets") + if socket.assigns.buffer_timer, do: Process.cancel_timer(socket.assigns.buffer_timer) # Clean up any pending bounds update timer if socket.assigns[:bounds_update_timer] do