diff --git a/src/app.rs b/src/app.rs index 400544a..873c130 100644 --- a/src/app.rs +++ b/src/app.rs @@ -19,6 +19,7 @@ mod sync; pub(super) const MAX_CONCURRENT_BLOB_TRANSFERS: usize = 4; pub(super) const MAX_CONCURRENT_PEER_REQUESTS: usize = 4; const INVITE_TTL: Duration = Duration::hours(24); +const INVITE_ONLINE_WAIT_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(5); const OWNER_DISPLAY_NAME: &str = "owner"; const JOINED_DEVICE_DISPLAY_NAME: &str = "joined device"; @@ -173,7 +174,8 @@ impl AppaService { .state_store .load_roster(folder.id)? .ok_or_else(|| anyhow::anyhow!("folder has no signed roster"))?; - node.wait_until_online().await?; + node.wait_until_online_for(INVITE_ONLINE_WAIT_TIMEOUT) + .await?; let mut invite = Invite { protocol_version: PROTOCOL_VERSION, folder_id: folder.id, diff --git a/src/iroh.rs b/src/iroh.rs index 9945c97..a179b68 100644 --- a/src/iroh.rs +++ b/src/iroh.rs @@ -154,9 +154,18 @@ impl NodeHost { } pub async fn wait_until_online(&self) -> anyhow::Result<()> { - tokio::time::timeout(ONLINE_WAIT_TIMEOUT, self.endpoint.online()) + self.wait_until_online_for(ONLINE_WAIT_TIMEOUT).await + } + + pub async fn wait_until_online_for(&self, timeout: std::time::Duration) -> anyhow::Result<()> { + tokio::time::timeout(timeout, self.endpoint.online()) .await - .map_err(|_| anyhow::anyhow!("timed out waiting for Iroh network connectivity"))?; + .map_err(|_| { + anyhow::anyhow!( + "timed out waiting {} seconds for Iroh network connectivity", + timeout.as_secs() + ) + })?; Ok(()) } pub fn endpoint_address(&self) -> EndpointAddr {