From fbacb944954787bc10dff12c20477a278199e78e Mon Sep 17 00:00:00 2001 From: jj Date: Tue, 26 Nov 2024 14:02:16 +0000 Subject: [PATCH] api/cookie: do not recreate interval if it already exists --- api/src/processing/cookie/manager.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/src/processing/cookie/manager.js b/api/src/processing/cookie/manager.js index 946ab70a..fb5ca1b6 100644 --- a/api/src/processing/cookie/manager.js +++ b/api/src/processing/cookie/manager.js @@ -27,6 +27,7 @@ function writeChanges(cookiePath) { console.warn(`${Yellow('[!]')} failed writing updated cookies to storage`); console.warn(e); clearInterval(intervalId); + intervalId = null; }) } @@ -47,7 +48,9 @@ const setupMain = async (cookiePath) => { delete cookies[serviceName]; } - intervalId = setInterval(() => writeChanges(cookiePath), WRITE_INTERVAL); + if (!intervalId) { + intervalId = setInterval(() => writeChanges(cookiePath), WRITE_INTERVAL); + } cluster.broadcast({ cookies });