diff --git a/extension/js/common/core/common.ts b/extension/js/common/core/common.ts index 5bd479a712d..6601cdd90ee 100644 --- a/extension/js/common/core/common.ts +++ b/extension/js/common/core/common.ts @@ -406,7 +406,9 @@ export class Url { * todo - the camelCase or snake_case functionality can now be removed */ public static parse = (expectedKeys: string[], parseThisUrl?: string) => { - const url = parseThisUrl || window.location.search.replace('?', ''); + const replacedLocation = typeof window !== 'undefined' ? window.location.search.replace('?', '') : 'https://service-worker.context'; // Placeholder URL when running in a service‐worker context + + const url = parseThisUrl ?? replacedLocation; const valuePairs = url.split('?').pop()?.split('&') ?? []; // str.split('?') string[].length will always be >= 1 const rawParams = new Map(); diff --git a/extension/js/service_worker/background.ts b/extension/js/service_worker/background.ts index 0ecf489c014..fd8e9800d12 100644 --- a/extension/js/service_worker/background.ts +++ b/extension/js/service_worker/background.ts @@ -22,6 +22,7 @@ console.info('background.js service worker starting'); let db: IDBDatabase; let storage: GlobalStoreDict; const inMemoryStore = new ExpirationCache('in_memory_store', 4 * 60 * 60 * 1000); // 4 hours + await chrome.alarms.clearAll(); await BrowserMsg.createIntervalAlarm('delete_expired', 1); // each minute try {