From 15adb30bc79c4b01425d6a2ff70d8ba8439a893b Mon Sep 17 00:00:00 2001 From: "Abiba (pi)" Date: Sun, 28 Jun 2026 11:28:57 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20raise=20MAX=5FCONSECUTIVE=5FEMPTY=5FPOLL?= =?UTF-8?q?S=2020=E2=86=92500=20to=20prevent=20idle=20reconnection=20cycli?= =?UTF-8?q?ng?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bots with no incoming messages were reconnecting every ~60 seconds (20 polls × 3s interval). Raised to 500 polls (~25min) so idle bots don't cycle. Connection recovers immediately on BAD_EVENT_QUEUE_ID regardless of this counter. --- plugins/platforms/zulip/adapter.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/platforms/zulip/adapter.py b/plugins/platforms/zulip/adapter.py index 043afe6..7e48173 100644 --- a/plugins/platforms/zulip/adapter.py +++ b/plugins/platforms/zulip/adapter.py @@ -77,7 +77,7 @@ SELFTEST_TIMEOUT = 30 # seconds to wait for self-test response # Gen 4: Connection pool health HEARTBEAT_INTERVAL = 300 # Log heartbeat every 5 minutes -MAX_CONSECUTIVE_EMPTY_POLLS = 20 # Reset client after this many empty polls +MAX_CONSECUTIVE_EMPTY_POLLS = 500 # Reset client after this many empty polls (~25min at 3s interval). Raised from 20 to prevent idle bots from cycling reconnections. CLIENT_REUSE_LIMIT = 500 # Create fresh client every N polls to prevent connection leaks POLL_SILENCE_WARN_INTERVAL = 60 # Warn if no events received for this many seconds MAX_ERROR_LOG_LEN = 80 # Truncate error response bodies to avoid HTML spam @@ -1311,7 +1311,7 @@ def check_requirements() -> bool: """Check whether the Zulip adapter is installable.""" if not HTTPX_AVAILABLE: return False - site = os.getenv("ZULIP_SITE", "").strip() + site = os.getenv("ZULIP_SITE", "").strip() or os.getenv("ZULIP_URL", "").strip() email = os.getenv("ZULIP_EMAIL", "").strip() api_key = os.getenv("ZULIP_API_KEY", "").strip() return bool(site and email and api_key) @@ -1320,7 +1320,7 @@ def check_requirements() -> bool: def validate_config(config) -> bool: """Validate that the configured Zulip platform has credentials.""" extra = getattr(config, "extra", {}) or {} - site = extra.get("site") or os.getenv("ZULIP_SITE", "") + site = extra.get("site") or os.getenv("ZULIP_SITE", "") or os.getenv("ZULIP_URL", "") email = extra.get("email") or os.getenv("ZULIP_EMAIL", "") api_key = extra.get("api_key") or os.getenv("ZULIP_API_KEY", "") return bool(site and email and api_key) @@ -1333,7 +1333,7 @@ def is_connected(config) -> bool: def _env_enablement() -> Optional[dict]: """Seeds PlatformConfig.extra from env vars for env-only setups.""" - site = os.getenv("ZULIP_SITE", "").strip() + site = os.getenv("ZULIP_SITE", "").strip() or os.getenv("ZULIP_URL", "").strip() email = os.getenv("ZULIP_EMAIL", "").strip() api_key = os.getenv("ZULIP_API_KEY", "").strip() if not (site and email and api_key):