From 058208992a89e89fe4b2e8cc7928adcce06554f0 Mon Sep 17 00:00:00 2001 From: Codekloeppler Date: Thu, 11 Sep 2025 12:21:08 +0200 Subject: [PATCH] Do not panick on healthcheck connection error (#2145) * Handle unhappy flow Fix the healthcheck to handle not only the happy flow, but also errors like "connection refused" or "host unreachable". * Fix Typo in variable --- crates/cli/src/modules/database.rs | 35 +++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/crates/cli/src/modules/database.rs b/crates/cli/src/modules/database.rs index dd7fdc02..c9b1cd18 100644 --- a/crates/cli/src/modules/database.rs +++ b/crates/cli/src/modules/database.rs @@ -116,22 +116,27 @@ impl ServerCommands { format!("{}/healthz/{}", client.url, check.unwrap_or("ready".to_string())) - ) - .await - .unwrap(); - - match response.status() { - StatusCode::OK => { - eprintln!("Success") - }, - _ => { - eprintln!( - "Request failed: {}", - response.text().await.unwrap_result("fetch text") - ); - std::process::exit(1); + ).await; + match response { + Ok(resp) => { + match resp.status() { + StatusCode::OK => { + eprintln!("Success") + }, + _ => { + eprintln!( + "Request failed: {}", + resp.text().await.unwrap_result("fetch text") + ); + std::process::exit(1); + } + } } - } + Err(err) => { + eprintln!("Request failed: {}", err); + std::process::exit(1); + } + } } } }