From 580021bc8d889ed3e449e394a7cabe73856bf7ce Mon Sep 17 00:00:00 2001 From: Matthew Keeler Date: Tue, 30 Jul 2024 11:38:26 -0400 Subject: [PATCH] fix: Allow event retries even if initial request fails to connect --- launchdarkly-server-sdk/src/events/sender.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/launchdarkly-server-sdk/src/events/sender.rs b/launchdarkly-server-sdk/src/events/sender.rs index 7410c50..44edea3 100644 --- a/launchdarkly-server-sdk/src/events/sender.rs +++ b/launchdarkly-server-sdk/src/events/sender.rs @@ -107,8 +107,8 @@ where } }; - for attempt in 0..2 { - if attempt == 1 { + for attempt in 1..=2 { + if attempt == 2 { sleep(Duration::from_secs(1)).await; } @@ -134,6 +134,7 @@ where let response = match result { Ok(response) => response, + Err(_) if attempt == 1 => continue, Err(e) => { // It appears this type of error will not be an HTTP error. // It will be a closed connection, aborted write, timeout, etc.