Skip to content

Commit 7befd1b

Browse files
committed
Address PR comment
1 parent 3e7400f commit 7befd1b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/app-check/src/internal-api.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,18 @@ function createTokenRefresher(
264264

265265
if (state.token) {
266266
// issuedAtTime + (50% * total TTL) + 5 minutes
267-
const nextRefreshTimeMillis =
267+
let nextRefreshTimeMillis =
268268
state.token.issuedAtTimeMillis +
269269
(state.token.expireTimeMillis - state.token.issuedAtTimeMillis) *
270270
0.5 +
271271
5 * 60 * 1000;
272+
// Do not allow refresh time to be past (expireTime - 5 minutes)
273+
const latestAllowableRefresh =
274+
state.token.expireTimeMillis - 5 * 60 * 1000;
275+
nextRefreshTimeMillis = Math.min(
276+
nextRefreshTimeMillis,
277+
latestAllowableRefresh
278+
);
272279
return Math.max(0, nextRefreshTimeMillis - Date.now());
273280
} else {
274281
return 0;

0 commit comments

Comments
 (0)