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

This commit is contained in:
jj 2024-11-26 14:02:16 +00:00
parent a4cb6ada79
commit fbacb94495
No known key found for this signature in database

View file

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