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 | ||
| live | ||
| plugs | ||
| changelog_parser.ex | ||
| endpoint.ex | ||
| gettext.ex | ||
| gettext_helpers.ex | ||
| graphql_socket.ex | ||
| permissions.ex | ||
| plug_exceptions.ex | ||
| remote_ip.ex | ||
| router.ex | ||
| scoped_resource.ex | ||
| telemetry.ex | ||
| telemetry_filter.ex | ||
| user_auth.ex | ||