prop/lib/microwaveprop_web/live/live_stash_guard.ex
Graham McIntire 3e458fb76a
feat(nav): add EME menu item to map + weather sidebars
The top navbar in the root layout already linked to /eme, but the
in-page side sidebars on /map and /weather (mobile + desktop) skipped
straight from Path Calculator to Beacons. Adds the EME entry between
them in all four panels so the Earth-Moon-Earth calculator is reachable
without bouncing through the navbar.

Also demotes the LiveStashGuard "stash skipped" warning to debug. It's
the known OTP 28 / LiveStash 0.2.0 ArgumentError that fires on every
event triggering a stash; the guard already handles it, the noise was
adding nothing.
2026-04-25 09:49:06 -05:00

37 lines
1.2 KiB
Elixir

defmodule MicrowavepropWeb.LiveStashGuard do
@moduledoc """
Tiny wrapper around `LiveStash.stash/1` that swallows the
`ArgumentError: not a valid match specification` crash LiveStash 0.2.0
raises under OTP 28.
The stash is a convenience for state persistence across reconnects;
a failure is not fatal to the user's session. We log and return the
socket unchanged instead of letting the LiveView process terminate
mid-`handle_event`.
Remove this module and inline `LiveStash.stash/1` calls once the
upstream match-spec fix lands in the `live_stash` hex package.
"""
alias Phoenix.LiveView.Socket
require Logger
@doc """
Best-effort wrapper around `LiveStash.stash/1`.
Returns the (possibly unchanged) socket no matter what the adapter
raises.
"""
@spec stash(Socket.t()) :: Socket.t()
def stash(socket) do
LiveStash.stash(socket)
rescue
e in ArgumentError ->
# Expected on OTP 28 with LiveStash 0.2.0 — fires on every event
# that triggers a stash. Log at debug so the cause stays
# observable without flooding prod logs.
Logger.debug("LiveStashGuard: stash skipped (#{Exception.message(e)})")
socket
end
end