Commit 2a24ce5173

2a24ce51736983c4d7942792593d05e73988f184

parent: e02e5a4787

Unsigned

Darafei Praliaskouski <me@komzpa.net> · 2026-06-30 16:23 UTC
committer: <strk@kbt.io>

fix: time out stalled room joins

Layout: unified · split

src/server.rs +21 −7
@@ -62,6 +62,7 @@ use std::{
6262 io::Write,
6363 path::{Path, PathBuf},
6464 rc::{Rc, Weak},
65 time::Duration,
6566};
6667use tracing::error;
6768use url::Url;
@@ -92,6 +93,8 @@ use weechat::{
9293 Prefix, Weechat,
9394};
9495
96const JOIN_ROOM_TIMEOUT: Duration = Duration::from_secs(120);
97
9598use crate::{
9699 config::ServerBuffer,
97100 connection::{Connection, InteractiveAuthInfo},
@@ -235,29 +238,40 @@ impl MatrixServer {
235238 let target = room_id_or_alias.to_string();
236239 let result = connection
237240 .spawn(async move {
238 let servers =
239 resolve_alias_servers(&client, &room_id_or_alias).await;
241 tokio::time::timeout(JOIN_ROOM_TIMEOUT, async move {
242 let servers =
243 resolve_alias_servers(&client, &room_id_or_alias).await;
240244
241 client
242 .join_room_by_id_or_alias(&room_id_or_alias, &servers)
243 .await
245 client
246 .join_room_by_id_or_alias(&room_id_or_alias, &servers)
247 .await
248 })
249 .await
244250 })
245251 .await;
246252
247253 match result {
248 Ok(room) => {
254 Ok(Ok(room)) => {
249255 self.print_network(&format!(
250256 "Successfully joined room {}",
251257 room.room_id()
252258 ));
253259 }
254 Err(error) => {
260 Ok(Err(error)) => {
255261 self.print_error(&format!(
256262 "Failed to join {}: {}",
257263 target,
258264 format_join_error(&error, &target)
259265 ));
260266 }
267 Err(error) => {
268 self.print_error(&format!(
269 "Timed out joining {} after {} seconds: {}",
270 target,
271 JOIN_ROOM_TIMEOUT.as_secs(),
272 error
273 ));
274 }
261275 }
262276 }
263277