diff --git a/lib/aprsme_web/live/map_live/data_builder.ex b/lib/aprsme_web/live/map_live/data_builder.ex index 4458a67..637a61e 100644 --- a/lib/aprsme_web/live/map_live/data_builder.ex +++ b/lib/aprsme_web/live/map_live/data_builder.ex @@ -43,16 +43,19 @@ defmodule AprsmeWeb.MapLive.DataBuilder do weather_set = Aprsme.Packets.weather_callsigns(callsigns) Process.put(:weather_callsigns_cache, weather_set) - result = + # try/after so the cache is cleared even if packet building raises — + # otherwise a leftover :weather_callsigns_cache entry would poison + # subsequent calls on the same LiveView process. + try do packets_map |> Enum.map(fn {_callsign, packet} -> build_packet_data(packet, is_most_recent, locale) end) |> Enum.filter(& &1) |> deduplicate_by_callsign_group() - - Process.delete(:weather_callsigns_cache) - result + after + Process.delete(:weather_callsigns_cache) + end end @doc """