Skip to content

Commit ba5d46f

Browse files
authored
fix: Do not use the current timestamp as disabled-until (#129)
1 parent 84f8d36 commit ba5d46f

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
@@ -230,7 +230,7 @@ implement_http_transport! {
230230
};
231231
let client = client.build().unwrap();
232232

233-
let mut disabled = SystemTime::now();
233+
let mut disabled = None::<SystemTime>;
234234

235235
thread::Builder::new()
236236
.name("sentry-transport".to_string())
@@ -248,13 +248,16 @@ implement_http_transport! {
248248
}
249249

250250
// while we are disabled due to rate limits, skip
251-
let now = SystemTime::now();
252-
if let Ok(time_left) = disabled.duration_since(now) {
253-
sentry_debug!(
254-
"Skipping event send because we're disabled due to rate limits for {}s",
255-
time_left.as_secs()
256-
);
257-
continue;
251+
if let Some(ts) = disabled {
252+
if let Ok(time_left) = ts.duration_since(SystemTime::now()) {
253+
sentry_debug!(
254+
"Skipping event send because we're disabled due to rate limits for {}s",
255+
time_left.as_secs()
256+
);
257+
continue;
258+
} else {
259+
disabled = None;
260+
}
258261
}
259262

260263
match client
@@ -271,7 +274,7 @@ implement_http_transport! {
271274
.and_then(|x| x.to_str().ok())
272275
.and_then(parse_retry_after)
273276
{
274-
disabled = retry_after;
277+
disabled = Some(retry_after);
275278
}
276279
}
277280
}

0 commit comments

Comments
 (0)