Skip to content

Commit b27f3cf

Browse files
committed
fix: Also correctly handle retry-after for curl
1 parent b4ab365 commit b27f3cf

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/transport.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ implement_http_transport! {
312312
let http_proxy = options.http_proxy.as_ref().map(|x| x.to_string());
313313
let https_proxy = options.https_proxy.as_ref().map(|x| x.to_string());
314314

315-
let mut disabled = SystemTime::now();
315+
let mut disabled = None::<SystemTime>;
316316
let mut handle = curl::easy::Easy::new();
317317

318318
thread::spawn(move || {
@@ -329,13 +329,16 @@ implement_http_transport! {
329329
}
330330

331331
// while we are disabled due to rate limits, skip
332-
let now = SystemTime::now();
333-
if let Ok(time_left) = disabled.duration_since(now) {
334-
sentry_debug!(
335-
"Skipping event send because we're disabled due to rate limits for {}s",
336-
time_left.as_secs()
337-
);
338-
continue;
332+
if let Some(ts) = disabled {
333+
if let Ok(time_left) = ts.duration_since(SystemTime::now()) {
334+
sentry_debug!(
335+
"Skipping event send because we're disabled due to rate limits for {}s",
336+
time_left.as_secs()
337+
);
338+
continue;
339+
} else {
340+
disabled = None;
341+
}
339342
}
340343

341344
handle.reset();
@@ -397,7 +400,7 @@ implement_http_transport! {
397400
.map(|x| x.as_str())
398401
.and_then(parse_retry_after)
399402
{
400-
disabled = retry_after;
403+
disabled = Some(retry_after);
401404
}
402405
}
403406
Ok(200) | Ok(201) => {}

0 commit comments

Comments
 (0)