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

Handle status for response #10

Merged
merged 5 commits into from
Feb 1, 2024
Merged

Handle status for response #10

merged 5 commits into from
Feb 1, 2024

Conversation

riya-n
Copy link
Contributor

@riya-n riya-n commented Jan 26, 2024

No description provided.

src/clients.rs Outdated Show resolved Hide resolved
src/clients.rs Outdated
@@ -7,6 +7,15 @@ use crate::types::{BundleUploadLocation, Repo};
pub const TRUNK_API_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
pub const TRUNK_API_TOKEN_HEADER: &str = "x-api-token";

fn handle_upload_bundle_error_logs(status: Option<reqwest::StatusCode>) {
log::error!("Failed to create bundle upload. Status: {:?}", status);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should keep the output concise to a single helpful error message.

src/clients.rs Outdated
return Err(anyhow::anyhow!(e).context("Failed to create bundle upload"));
}
};

if resp.status() != reqwest::StatusCode::OK {
handle_upload_bundle_error_logs(Some(resp.status()));
Copy link
Contributor

@zaycev zaycev Jan 30, 2024

Choose a reason for hiding this comment

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

I would consider only appending information to context here and moving error logging into a common error-handling location inside main.rs. Otherwise, it seems like we might be double-logging.

src/main.rs Outdated
@@ -68,7 +68,7 @@ const DEFAULT_API_ADDRESS: &str = "https://api.trunk.io/v1/metrics/createBundleU
// This will give us 8ms, 64ms, 512ms, 4096ms, 32768ms
const RETRY_BASE_MS: u64 = 8;
const RETRY_FACTOR: u64 = 1;
const RETRY_COUNT: usize = 5;
const RETRY_COUNT: usize = 3;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see why we need to retry 5 times. When making a request with incorrect token, this takes 40 seconds to complete and log the error. With retry 3 times, it only takes a couple of seconds.

Copy link
Contributor

@zaycev zaycev Feb 1, 2024

Choose a reason for hiding this comment

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

Why do we want to reduce from 40s to 3s though? That's a point of retrying – give backend time to auto-resolve some transient issue.

@riya-n riya-n requested a review from zaycev February 1, 2024 19:57
@riya-n riya-n merged commit 55b0a1c into main Feb 1, 2024
3 checks passed
@riya-n riya-n deleted the riya/new-branch branch February 1, 2024 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants