From 22292eccabcdf36129845e6fd03d0c5e2516c3be Mon Sep 17 00:00:00 2001 From: Serguey Parkhomovsky Date: Sat, 21 Mar 2026 11:46:51 -0700 Subject: Add timeout to http client --- src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 8018bed..433209c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -127,7 +127,13 @@ async fn fetch_prusa( } async fn poll_prusa(name: String, host: String, api_key: String, state: StateMap) { - let client = Client::new(); + let client = Client::builder() + .timeout(Duration::from_secs(10)) + .build() + .unwrap_or_else(|e| { + error!(name, error = %e, "Failed to build HTTP client"); + process::exit(1); + }); loop { if let Err(e) = fetch_prusa(&client, &name, &host, &api_key, &state).await { error!(name, error = %e, "Error polling Prusa printer"); -- cgit v1.2.3