fix: handle missing :pending_batch_tasks assign in historical loader
Some checks failed
Elixir CI / Build and test (push) Failing after 3m28s
Elixir CI / Dialyzer (push) Successful in 3m54s
Elixir CI / Build and Push Docker Image (push) Has been skipped

Use Map.get with default for all loading_generation and pending_batch_tasks
socket.assigns accesses to prevent KeyError when key is not present.
This commit is contained in:
Graham McIntire 2026-08-06 17:52:53 -05:00
parent d63cdf4cda
commit b93d4904a3
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -113,7 +113,7 @@ defmodule AprsmeWeb.MapLive.HistoricalLoader do
@spec cancel_pending_loads(Socket.t()) :: Socket.t()
def cancel_pending_loads(socket) do
# Cancel any pending batch load messages
Enum.each(socket.assigns.pending_batch_tasks, &Process.cancel_timer/1)
Enum.each(Map.get(socket.assigns, :pending_batch_tasks, []), &Process.cancel_timer/1)
assign(socket, :pending_batch_tasks, [])
end
@ -333,7 +333,7 @@ defmodule AprsmeWeb.MapLive.HistoricalLoader do
generation = Map.get(socket.assigns, :loading_generation, 0)
timer_ref = Process.send_after(self(), {:load_historical_batch, next_batch, generation}, 50)
assign(socket, :pending_batch_tasks, [timer_ref | socket.assigns.pending_batch_tasks])
assign(socket, :pending_batch_tasks, [timer_ref | Map.get(socket.assigns, :pending_batch_tasks, [])])
end
# Handle low zoom (heat map)