Skip to content

Commit 30852fa

Browse files
committed
chore: cleanup debug logging
1 parent a1a2cbf commit 30852fa

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

ts/session/revocation_list/pro_revocation_list.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,12 @@ async function loadFromDbIfNeeded() {
2424

2525
const resetItems: ProRevocationItemsDBType = [];
2626
if (!isString(itemsFromDb) || !itemsFromDb) {
27-
// reset the cache and the DB entry manually (not calling setListItems here)
28-
await Storage.put(SettingsKey.proRevocationListItems, JSON.stringify(resetItems));
29-
cachedProRevocationListItems = resetItems;
27+
await setListItems(resetItems, false);
3028
} else {
3129
try {
3230
const parsedJsonItems = JSON.parse(itemsFromDb);
3331
if (!isArray(parsedJsonItems)) {
34-
await Storage.put(SettingsKey.proRevocationListItems, JSON.stringify(resetItems));
35-
cachedProRevocationListItems = resetItems;
32+
await setListItems(resetItems, false);
3633
} else {
3734
const parsed = ProRevocationItemsDBSchema.safeParse(parsedJsonItems);
3835

@@ -43,17 +40,15 @@ async function loadFromDbIfNeeded() {
4340
'failed to parse pro revocation list items from storage, resetting to []. error:',
4441
parsed.error
4542
);
46-
await Storage.put(SettingsKey.proRevocationListItems, JSON.stringify(resetItems));
47-
cachedProRevocationListItems = resetItems;
43+
await setListItems(resetItems, false);
4844
}
4945
}
5046
} catch (e) {
5147
window.log.warn(
5248
'failed to parse pro revocation list items from storage, resetting to []. error:',
5349
e.message
5450
);
55-
await Storage.put(SettingsKey.proRevocationListItems, JSON.stringify(resetItems));
56-
cachedProRevocationListItems = resetItems;
51+
await setListItems(resetItems, false);
5752
}
5853
}
5954

@@ -85,8 +80,10 @@ async function getListItems(): Promise<ProRevocationItemsDBType> {
8580
return cachedProRevocationListItems;
8681
}
8782

88-
async function setListItems(items: ProRevocationItemsDBType) {
89-
assertInitialFetchFromDBDone('setListItems');
83+
async function setListItems(items: ProRevocationItemsDBType, assertLoaded = true) {
84+
if (assertLoaded) {
85+
assertInitialFetchFromDBDone('setListItems');
86+
}
9087

9188
await Storage.put(SettingsKey.proRevocationListItems, JSON.stringify(items));
9289
cachedProRevocationListItems = items;

ts/session/utils/job_runners/jobs/UpdateProRevocationListJob.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@ class UpdateProRevocationListJob extends PersistedJob<UpdateProRevocationListPer
101101

102102
const retryInSecondsFromBackend = response.result.retry_in_s;
103103
const retryInSeconds = Math.max(retryInSecondsFromBackend, 0);
104+
104105
const retryAtMs = Date.now() + toNumber(retryInSeconds) * DURATION.SECONDS;
105106

106107
window.log.debug(
107-
`UpdateProRevocationListJob: got 'retry_in_s' from server: ${retryInSeconds}, i.e retryAtMs: ${retryAtMs}`
108+
`UpdateProRevocationListJob: got 'retry_in_s' from server: ${retryInSeconds}, i.e we will retryAtMs: ${retryAtMs}`
108109
);
109110
await updateNextRunAtMs(retryAtMs);
110111

@@ -208,11 +209,14 @@ async function queueNewJobIfNeeded() {
208209
);
209210
return;
210211
}
212+
const postponedSeconds = 20;
211213
window.log.debug(
212-
`Scheduling UpdateProRevocationListJob.... refreshedNextRunAtMs: ${refreshedNextRunAtMs} and now: ${now}`
214+
`Scheduling UpdateProRevocationListJob in ${postponedSeconds}s. refreshedNextRunAtMs: ${refreshedNextRunAtMs} and now: ${now}`
213215
);
214216
await runners.updateProRevocationListRunner.addJob(
215-
new UpdateProRevocationListJob({ nextAttemptTimestamp: Date.now() + 20 * DURATION.SECONDS })
217+
new UpdateProRevocationListJob({
218+
nextAttemptTimestamp: Date.now() + postponedSeconds * DURATION.SECONDS,
219+
})
216220
);
217221
}
218222

0 commit comments

Comments
 (0)