From d7b49fa6714ffeca71127a711f819fa4285c6a94 Mon Sep 17 00:00:00 2001 From: mpostma Date: Mon, 22 Jun 2020 19:53:56 +0200 Subject: [PATCH] fix potential infinite loop --- meilisearch-http/tests/common.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/meilisearch-http/tests/common.rs b/meilisearch-http/tests/common.rs index 89724f379..b4e3b35f5 100644 --- a/meilisearch-http/tests/common.rs +++ b/meilisearch-http/tests/common.rs @@ -111,17 +111,19 @@ impl Server { pub async fn wait_update_id(&mut self, update_id: u64) { - loop { + // try 10 times to get status, or panic to not wait forever + for _ in 1..10 { let (response, status_code) = self.get_update_status(update_id).await; assert_eq!(status_code, 200); - if response["status"] == "processed" || response["status"] == "error" { + if response["status"] == "processed" || response["status"] == "failed" { eprintln!("{:#?}", response); return; } delay_for(Duration::from_secs(1)).await; } + panic!("Timeout waiting for update id"); } // Global Http request GET/POST/DELETE async or sync