Log error instead of silently returning 0 in now_ms
Richard Feldman
created
If the system clock is before the UNIX epoch, the silent unwrap_or(0)
would cause broken credential expiry behavior. Now the error is
visible in logs.
Change summary
crates/language_models/src/provider/openai_subscribed.rs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Detailed changes
@@ -821,7 +821,10 @@ fn now_ms() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.map(|d| d.as_millis() as u64)
- .unwrap_or(0)
+ .unwrap_or_else(|err| {
+ log::error!("System clock is before UNIX epoch: {err}");
+ 0
+ })
}
fn do_sign_in(state: &Entity<State>, http_client: &Arc<dyn HttpClient>, cx: &mut App) {