When an agent joins, we update last_seen_at in the database but don't set last_heartbeat_db_update in the socket. This causes the heartbeat throttling logic to be out of sync: - On join: DB updated, but last_heartbeat_db_update not set (nil) - First heartbeat: Updates DB again because last_heartbeat_db_update is nil - Subsequent heartbeats: Check if >30s since last DB update - Problem: last_heartbeat_db_update tracks the first heartbeat, not the join DB update This manifests when Phoenix recompiles during development - the channel process continues running with old socket assigns, and if last_heartbeat_db_update is recent, heartbeats won't update the DB. After 10+ minutes without DB updates, the agent appears offline even though it's still connected. Fix: Set last_heartbeat_db_update when we update the DB on join, so the throttling logic accurately tracks the most recent DB update. Reviewed-on: graham/towerops-web#142 |
||
|---|---|---|
| .. | ||
| channels | ||
| components | ||
| controllers | ||
| graphql | ||
| helpers | ||
| integration | ||
| live | ||
| plugs | ||
| gleam_changelog_parser_test.exs | ||
| graphql_socket_test.exs | ||
| permissions_test.exs | ||
| plug_exceptions_test.exs | ||
| remote_ip_test.exs | ||
| telemetry_filter_test.exs | ||
| user_auth_test.exs | ||