Skip to content

Commit dc675c4

Browse files
authored
fix: update token scheduler to use dynamic expiration and renewal intervals (#402)
1 parent f42ea1c commit dc675c4

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/apps/main/auth/refresh-token/create-token-schedule-with-retry.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ import { logger } from '@internxt/drive-desktop-core/build/backend';
55
import { refreshToken } from './refresh-token';
66

77
const CREATE_SCHEDULE_RETRY_LIMIT = 3;
8+
const TOKEN_EXPIRATION_HOURS = 12;
9+
const TOKEN_RENEW_INTERVAL_HOURS = 4;
10+
const TOKEN_RENEW_BEFORE_EXPIRATION_DAYS = (TOKEN_EXPIRATION_HOURS - TOKEN_RENEW_INTERVAL_HOURS) / 24;
811

912
export async function createTokenScheduleWithRetry() {
1013
const { newToken } = getCredentials();
11-
const tokenScheduler = new TokenScheduler(5, newToken, closeUserSession);
14+
const tokenScheduler = new TokenScheduler(TOKEN_RENEW_BEFORE_EXPIRATION_DAYS, newToken, closeUserSession);
1215

1316
let attempt = 0;
1417
while (attempt < CREATE_SCHEDULE_RETRY_LIMIT) {

0 commit comments

Comments
 (0)