From c5677df56e1b90d2390acb91bc5784f4a657a687 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 30 Nov 2025 18:03:19 +0000 Subject: [PATCH] Increase watchdog timeout to 30 minutes Changed from 10 to 30 minutes to avoid false positives when heartbeatMinutes is set to 10. The watchdog should be significantly longer than the heartbeat interval to account for: - Network latency - Slow command responses - Brief connection hiccups With heartbeatMinutes=10, a 30-minute watchdog gives 3x buffer before triggering auto-restart. --- CHANGELOG.md | 2 +- src/web/auto-reply.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e68934d8b..ba6829ada 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 1.2.3 — Unreleased ### Changes -- **Auto-recovery from stuck WhatsApp sessions:** Added watchdog timer that detects when WhatsApp event emitter stops firing (e.g., after Bad MAC decryption errors) and automatically restarts the connection after 10 minutes of no message activity. Heartbeat logging now includes `minutesSinceLastMessage` and warns when >30 minutes without messages. +- **Auto-recovery from stuck WhatsApp sessions:** Added watchdog timer that detects when WhatsApp event emitter stops firing (e.g., after Bad MAC decryption errors) and automatically restarts the connection after 30 minutes of no message activity. Heartbeat logging now includes `minutesSinceLastMessage` and warns when >30 minutes without messages. The 30-minute timeout is intentionally longer than typical `heartbeatMinutes` configs to avoid false positives. - **Early allowFrom filtering:** Unauthorized senders are now blocked in `inbound.ts` BEFORE encryption/decryption attempts, preventing Bad MAC errors from corrupting session state. Previously, messages from unauthorized senders would trigger decryption failures that could silently kill the event emitter. - **Test isolation improvements:** Mock `loadConfig()` in all test files to prevent loading real user config (with emojis/prefixes) during tests. Default test config now has no prefixes/timestamps for cleaner assertions. - **Same-phone mode (self-messaging):** warelay now supports running on the same phone number you message from. This enables setups where you chat with yourself to control an AI assistant. Same-phone mode (`from === to`) is always allowed, even without configuring `allowFrom`. Echo detection prevents infinite loops by tracking recently sent message text and skipping auto-replies when incoming messages match. diff --git a/src/web/auto-reply.ts b/src/web/auto-reply.ts index 040ca31f6..2b1c358ff 100644 --- a/src/web/auto-reply.ts +++ b/src/web/auto-reply.ts @@ -518,7 +518,8 @@ export async function monitorWebProvider( let lastInboundMsg: WebInboundMsg | null = null; // Watchdog to detect stuck message processing (e.g., event emitter died) - const MESSAGE_TIMEOUT_MS = 10 * 60 * 1000; // 10 minutes without any messages + // Should be significantly longer than heartbeatMinutes to avoid false positives + const MESSAGE_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes without any messages const WATCHDOG_CHECK_MS = 60 * 1000; // Check every minute const listener = await (listenerFactory ?? monitorWebInbox)({