Skip to content

best way to save what you love

api/cookie: do not recreate interval if it already exists

jjfbacb9449547
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 });