fix channel shutnown exception

This commit is contained in:
Graham McIntire 2026-02-13 08:29:15 -06:00
parent 4174987a88
commit 38a0681bf7
No known key found for this signature in database
2 changed files with 13 additions and 3 deletions

View file

@ -1,3 +1,13 @@
2026-02-13
fix: prevent agent channel graceful shutdowns from being logged as exceptions
- Changed Phoenix Channel stop reasons to use {:shutdown, reason} tuple instead
of bare atoms to signal graceful termination
- Updated heartbeat_timeout, token_disabled, and restart_requested handlers
- Prevents error tracking systems from incorrectly reporting normal agent
disconnections as ErlangError exceptions
- These events are expected operational occurrences (timeouts, admin actions)
- File: lib/towerops_web/channels/agent_channel.ex
2026-02-12
feat: complete migration from DevicePollerWorker to CheckExecutorWorker
- Removed all DevicePollerWorker scheduling from device lifecycle

View file

@ -193,7 +193,7 @@ defmodule ToweropsWeb.AgentChannel do
agent_token_id: socket.assigns.agent_token_id
)
{:stop, :heartbeat_timeout, socket}
{:stop, {:shutdown, :heartbeat_timeout}, socket}
else
Process.send_after(self(), :check_heartbeat, @heartbeat_check_interval_ms)
{:noreply, socket}
@ -206,7 +206,7 @@ defmodule ToweropsWeb.AgentChannel do
agent_token_id: socket.assigns.agent_token_id
)
{:stop, :token_disabled, socket}
{:stop, {:shutdown, :token_disabled}, socket}
end
# Handle restart request — push restart event to agent, then stop channel
@ -216,7 +216,7 @@ defmodule ToweropsWeb.AgentChannel do
)
push(socket, "restart", %{})
{:stop, :restart_requested, socket}
{:stop, {:shutdown, :restart_requested}, socket}
end
# Handle update request — push update event with download URL and checksum to agent