From 0fc9430056360fe95618db55f59c89f3877d9169 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Mar 2026 23:01:07 +0000 Subject: [PATCH 1/3] Initial plan From dfe03155a595e5430eddc940515a01c3b6a646c5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Mar 2026 23:02:56 +0000 Subject: [PATCH 2/3] fix: guard setInterval with globalThis to prevent multiple cleanup loops Co-authored-by: ormidales <46538211+ormidales@users.noreply.github.com> --- background.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/background.js b/background.js index 8362d4f..699b232 100644 --- a/background.js +++ b/background.js @@ -126,7 +126,10 @@ const cleanupStaleTrackedRequests = (now = Date.now()) => { } }; -setInterval(cleanupStaleTrackedRequests, REQUEST_TRACK_TTL_MS); +if (globalThis.cleanupIntervalId) { + clearInterval(globalThis.cleanupIntervalId); +} +globalThis.cleanupIntervalId = setInterval(cleanupStaleTrackedRequests, REQUEST_TRACK_TTL_MS); const updateExceptionDomains = (domains = []) => { exceptionDomains.clear(); From 874cebba1010bcf32a0cbaafc4000f74e6ac22eb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Mar 2026 11:45:20 +0000 Subject: [PATCH 3/3] fix: namespace globalThis interval key and add type guard before clearInterval Co-authored-by: ormidales <46538211+ormidales@users.noreply.github.com> --- background.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/background.js b/background.js index 699b232..12ee5ac 100644 --- a/background.js +++ b/background.js @@ -126,10 +126,12 @@ const cleanupStaleTrackedRequests = (now = Date.now()) => { } }; -if (globalThis.cleanupIntervalId) { - clearInterval(globalThis.cleanupIntervalId); +const CLEANUP_INTERVAL_KEY = "__acceptLangExt_cleanupIntervalId"; +const existingCleanupIntervalId = globalThis[CLEANUP_INTERVAL_KEY]; +if (typeof existingCleanupIntervalId === "number" || typeof existingCleanupIntervalId === "object") { + clearInterval(existingCleanupIntervalId); } -globalThis.cleanupIntervalId = setInterval(cleanupStaleTrackedRequests, REQUEST_TRACK_TTL_MS); +globalThis[CLEANUP_INTERVAL_KEY] = setInterval(cleanupStaleTrackedRequests, REQUEST_TRACK_TTL_MS); const updateExceptionDomains = (domains = []) => { exceptionDomains.clear();