fix(data_builder): clear weather cache in after block
If build_packet_data raises, the :weather_callsigns_cache process-dict entry would stick around and poison subsequent unrelated calls on the same LiveView process. Wrap the building pass in try/after so the key is always removed.
This commit is contained in:
parent
2fc4706d3d
commit
c64ad4d571
1 changed files with 7 additions and 4 deletions
|
|
@ -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 """
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue