From fc902a9cebfb8e0b46acb03e75e467922a3e61bb Mon Sep 17 00:00:00 2001 From: ww Date: Sat, 28 Mar 2026 00:59:42 +0800 Subject: [PATCH] channels: add startup timeout for telegram control-plane calls (cherry picked from commit 7432086493f3c9d1da1073efc000b6284f65496c) --- crates/openfang-channels/src/telegram.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/openfang-channels/src/telegram.rs b/crates/openfang-channels/src/telegram.rs index b1b7feef..6435b558 100644 --- a/crates/openfang-channels/src/telegram.rs +++ b/crates/openfang-channels/src/telegram.rs @@ -25,6 +25,8 @@ const MAX_BACKOFF: Duration = Duration::from_secs(60); const INITIAL_BACKOFF: Duration = Duration::from_secs(1); /// Telegram long-polling timeout (seconds) — sent as the `timeout` parameter to getUpdates. const LONG_POLL_TIMEOUT: u64 = 30; +/// Bound startup control-plane calls so a flaky Local Bot API cannot block daemon boot forever. +const STARTUP_API_TIMEOUT: Duration = Duration::from_secs(10); /// Default Telegram Bot API base URL. const DEFAULT_API_URL: &str = "https://api.telegram.org"; @@ -120,6 +122,7 @@ impl TelegramAdapter { let resp: serde_json::Value = self .client .post(&url) + .timeout(STARTUP_API_TIMEOUT) .json(&serde_json::json!({ "commands": commands })) .send() .await? @@ -468,6 +471,7 @@ impl ChannelAdapter for TelegramAdapter { .client .post(&delete_url) .json(&serde_json::json!({"drop_pending_updates": true})) + .timeout(STARTUP_API_TIMEOUT) .send() .await {