File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -256,11 +256,18 @@ function createTokenRefresher(app: FirebaseApp): Refresher {
256
256
257
257
if ( state . token ) {
258
258
// issuedAtTime + (50% * total TTL) + 5 minutes
259
- const nextRefreshTimeMillis =
259
+ let nextRefreshTimeMillis =
260
260
state . token . issuedAtTimeMillis +
261
261
( state . token . expireTimeMillis - state . token . issuedAtTimeMillis ) *
262
262
0.5 +
263
263
5 * 60 * 1000 ;
264
+ // Do not allow refresh time to be past (expireTime - 5 minutes)
265
+ const latestAllowableRefresh =
266
+ state . token . expireTimeMillis - 5 * 60 * 1000 ;
267
+ nextRefreshTimeMillis = Math . min (
268
+ nextRefreshTimeMillis ,
269
+ latestAllowableRefresh
270
+ ) ;
264
271
return Math . max ( 0 , nextRefreshTimeMillis - Date . now ( ) ) ;
265
272
} else {
266
273
return 0 ;
You can’t perform that action at this time.
0 commit comments