Skip to content

fix(bot): liveness watchdog — silent getUpdates stall now self-heals in seconds - #97

Merged
Pher217 merged 1 commit into
mainfrom
claude/2026-07-02-bot-watchdog
Jul 4, 2026
Merged

fix(bot): liveness watchdog — silent getUpdates stall now self-heals in seconds#97
Pher217 merged 1 commit into
mainfrom
claude/2026-07-02-bot-watchdog

Conversation

@Pher217

@Pher217 Pher217 commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Goal

Tonight's lost Telegram test: the bot consumed the update, then hung forever on an internal await (Redis channel-layer stall — same class the daemon fixed via heartbeat watchdog in PR #56). Process alive, zero log output, long-poll dead — every subsequent message silently lost until a manual restart. Documented as gotcha #26 with the non-destructive diagnosis (a no-offset getUpdates probe: healthy bot → 409 Conflict; hung bot → 200).

Change

  • Each completed getUpdates cycle (even empty) stamps a monotonic heartbeat.
  • A watchdog task checks every 60s; if no cycle completed within 300s it logs and os._exit(70)s — launchd KeepAlive restarts the bot within seconds. A stalled event loop can't be trusted to unwind cleanly, hence the hard exit.
  • Pure decision function watchdog_is_stalled() + 4 tests (fresh/stale decision, stall → exit(70), healthy loop never exits).

Test Summary

backend 542 passed, ruff clean.

After merge

Kickstart the bot once (launchctl kickstart -k gui/$(id -u)/com.openremote.bot) to pick up the code; from then on this failure mode self-heals.

…on silent stall

The bot hung mid-update-handling (a decayed Redis channel-layer await):
process alive, nothing logged, long-poll dead, inbound messages silently
lost (gotcha #26, live 2026-07-02 — diagnosed via a no-offset getUpdates
probe returning 200 instead of 409). Same failure class the daemon fixed
with its heartbeat watchdog in PR #56; the bot never got one.

A completed getUpdates cycle (even empty) now stamps a heartbeat; a
watchdog task hard-exits (os._exit 70) when no cycle completes within
300s so launchd KeepAlive restarts the bot with fresh connections.

backend: 542 passed. Ruff clean.
@Pher217 Pher217 self-assigned this Jul 2, 2026
@Pher217
Pher217 merged commit a52907c into main Jul 4, 2026
1 check passed
@Pher217
Pher217 deleted the claude/2026-07-02-bot-watchdog branch July 4, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant