From 2c83cd14c58703c6a36b9aaa8cabb2f7b25ea4b7 Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Fri, 15 Dec 2023 15:50:30 -0500 Subject: [PATCH] add timeouts to download request --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6b881da..f3fb2d2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,7 @@ use governor::{Quota, RateLimiter}; use reqwest::header::AUTHORIZATION; // ACCEPT, CONTENT_TYPE}; use serde::Deserialize; use tokio::io::AsyncBufReadExt; +use tokio::time::timeout; use tracing::{debug, error, info, warn}; use tracing_subscriber::filter::EnvFilter; @@ -683,9 +684,9 @@ async fn download_versions( req }; - let resp = req.send().await?; + let resp = timeout(Duration::from_secs(10), req.send()).await??; let status = resp.status(); - let body = resp.bytes().await?; + let body = timeout(Duration::from_secs(10), resp.bytes()).await??; if !status.is_success() { error!(status = ?status, "download failed");