Skip to content

Commit 4921ee5

Browse files
authored
Merge pull request #898 from tytsxai/pr/upstream-generic-fixes
channels: add startup timeout for Telegram control-plane calls
2 parents 0c4769a + fc902a9 commit 4921ee5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

crates/openfang-channels/src/telegram.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const MAX_BACKOFF: Duration = Duration::from_secs(60);
2525
const INITIAL_BACKOFF: Duration = Duration::from_secs(1);
2626
/// Telegram long-polling timeout (seconds) — sent as the `timeout` parameter to getUpdates.
2727
const LONG_POLL_TIMEOUT: u64 = 30;
28+
/// Bound startup control-plane calls so a flaky Local Bot API cannot block daemon boot forever.
29+
const STARTUP_API_TIMEOUT: Duration = Duration::from_secs(10);
2830

2931
/// Default Telegram Bot API base URL.
3032
const DEFAULT_API_URL: &str = "https://api.telegram.org";
@@ -120,6 +122,7 @@ impl TelegramAdapter {
120122
let resp: serde_json::Value = self
121123
.client
122124
.post(&url)
125+
.timeout(STARTUP_API_TIMEOUT)
123126
.json(&serde_json::json!({ "commands": commands }))
124127
.send()
125128
.await?
@@ -468,6 +471,7 @@ impl ChannelAdapter for TelegramAdapter {
468471
.client
469472
.post(&delete_url)
470473
.json(&serde_json::json!({"drop_pending_updates": true}))
474+
.timeout(STARTUP_API_TIMEOUT)
471475
.send()
472476
.await
473477
{

0 commit comments

Comments
 (0)