Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow event retries even if initial request fails to connect #93

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions launchdarkly-server-sdk/src/events/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ where
}
};

for attempt in 0..2 {
if attempt == 1 {
for attempt in 1..=2 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like it makes more sense to be 1-based in this situation, even though I typically prefer 0 based loops.

if attempt == 2 {
sleep(Duration::from_secs(1)).await;
}

Expand All @@ -134,6 +134,7 @@ where

let response = match result {
Ok(response) => response,
Err(_) if attempt == 1 => continue,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A customer opened an issue because their logs are filled with the message show in the other error branch. While this change doesn't necessarily fix their specific problem, it should help in a couple of ways.

  1. Originally, we were considering the original failure to be unrecoverable, which might not be true. So more events might start making it through.
  2. We won't log anything on the first failure, so if the failure is temporary, we won't unnecessarily alert customers.

Err(e) => {
// It appears this type of error will not be an HTTP error.
// It will be a closed connection, aborted write, timeout, etc.
Expand Down