From e8b143813e6cf587e81ff33f81c588de464ec684 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Mon, 1 Jun 2026 15:40:38 -0500 Subject: [PATCH] fix: add error handling to unsupervised Task.start calls in application.ex - Grid cache warm-up and ML model load now wrapped in try/rescue so silent failures are logged instead of lost --- lib/microwaveprop/application.ex | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/microwaveprop/application.ex b/lib/microwaveprop/application.ex index d6b1ef32..1696da37 100644 --- a/lib/microwaveprop/application.ex +++ b/lib/microwaveprop/application.ex @@ -97,7 +97,15 @@ defmodule Microwaveprop.Application do # master: when executed here the loaded rows live on the app master's # heap and never GC (it's idle after boot), pinning ~800 MiB for the # lifetime of the pod. - {:ok, _pid} = Task.start(fn -> Microwaveprop.Weather.warm_grid_cache_from_latest_profile() end) + {:ok, _pid} = + Task.start(fn -> + try do + Microwaveprop.Weather.warm_grid_cache_from_latest_profile() + rescue + e -> + Logger.error("Application: grid cache warm failed: #{Exception.format(:error, e, __STACKTRACE__)}") + end + end) # One-shot backfill: enqueue a QRZ-lookup job for every user with a # missing home QTH. Idempotent — the worker no-ops if home_grid is @@ -118,7 +126,12 @@ defmodule Microwaveprop.Application do if Application.get_env(:microwaveprop, :load_ml_model, false) do {:ok, _pid} = Task.start(fn -> - Microwaveprop.Propagation.load_ml_model() + try do + Microwaveprop.Propagation.load_ml_model() + rescue + e -> + Logger.error("Application: ML model load failed: #{Exception.format(:error, e, __STACKTRACE__)}") + end end) end