File tree 1 file changed +6
-2
lines changed
packages/app-lib/src/state
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -260,12 +260,16 @@ pub(super) static PROFILE_CACHE: Mutex<
260
260
> = Mutex :: const_new ( HashMap :: with_hasher ( BuildHasherDefault :: new ( ) ) ) ;
261
261
262
262
impl Credentials {
263
- /// Refreshes the authentication tokens for this user if they are expired.
263
+ /// Refreshes the authentication tokens for this user if they are expired, or
264
+ /// very close to expiration.
264
265
async fn refresh (
265
266
& mut self ,
266
267
exec : impl sqlx:: Executor < ' _ , Database = sqlx:: Sqlite > + Copy ,
267
268
) -> crate :: Result < ( ) > {
268
- if self . expires > Utc :: now ( ) {
269
+ // Use a margin of 5 minutes to give e.g. Minecraft and potentially
270
+ // other operations that depend on a fresh token 5 minutes to complete
271
+ // from now, and deal with some classes of clock skew
272
+ if self . expires > Utc :: now ( ) + Duration :: minutes ( 5 ) {
269
273
return Ok ( ( ) ) ;
270
274
}
271
275
You can’t perform that action at this time.
0 commit comments