From 38a0681bf753d87178a2b68de1fd24bfd3474820 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 13 Feb 2026 08:29:15 -0600 Subject: [PATCH] fix channel shutnown exception --- CHANGELOG.txt | 10 ++++++++++ lib/towerops_web/channels/agent_channel.ex | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 0b036add..b965f431 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 diff --git a/lib/towerops_web/channels/agent_channel.ex b/lib/towerops_web/channels/agent_channel.ex index 5f09fa83..46490dea 100644 --- a/lib/towerops_web/channels/agent_channel.ex +++ b/lib/towerops_web/channels/agent_channel.ex @@ -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