fix: bound ntfy read-back in doorbell heartbeat (avoid hang)

This commit is contained in:
2026-08-28 10:09:13 -07:00
parent 080c7c29bf
commit d5f5e640bc
@@ -21,14 +21,17 @@ else
# without us owning the service. # without us owning the service.
marker="canary-$(date +%s)-$$" marker="canary-$(date +%s)-$$"
url="https://ntfy.sh/${CANARY_TOPIC}" url="https://ntfy.sh/${CANARY_TOPIC}"
if ! curl -fsS -m 10 -o /dev/null -X POST "$url" -d "$marker" 2>/dev/null; then if ! curl -fsS -m 10 -o /dev/null -X POST "$url" -H "id: $marker" -d "$marker" 2>/dev/null; then
reason="${reason}ntfy_publish_failed" reason="${reason}ntfy_publish_failed"
else else
sleep 1 # Read back with poll+since, bounded by --max-time so the ntfy.sh
body=$(curl -fsS -m 10 "$url/json" 2>/dev/null) # stream doesn't hang the probe (plain /json keeps the connection open).
if [ -z "$body" ] || ! printf '%s' "$body" | grep -qF "$marker"; then tmp=$(mktemp)
curl -fsS --max-time 5 "$url/json?poll=1&since=$(($(date +%s)-5))" -o "$tmp" 2>/dev/null
if ! grep -qF "$marker" "$tmp"; then
reason="${reason}ntfy_echo_missing" reason="${reason}ntfy_echo_missing"
fi fi
rm -f "$tmp"
fi fi
fi fi