mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-11 06:11:15 +00:00
fix: clear timeout on race settlement to prevent orphaned timers
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -72,19 +72,20 @@ async function runCycle(): Promise<void> {
|
||||
log.info({ accountCount: accounts.length }, "Processing accounts");
|
||||
|
||||
const results = await Promise.allSettled(
|
||||
accounts.map((account) =>
|
||||
Promise.race([
|
||||
accounts.map((account) => {
|
||||
let timer: ReturnType<typeof setTimeout>;
|
||||
return Promise.race([
|
||||
withTdlibMutex(account.phone, `ingest:${account.phone}`, () =>
|
||||
runWorkerForAccount(account)
|
||||
),
|
||||
new Promise<never>((_, reject) =>
|
||||
setTimeout(
|
||||
new Promise<never>((_, reject) => {
|
||||
timer = setTimeout(
|
||||
() => reject(new Error(`Account ${account.phone} ingestion timed out after ${CYCLE_TIMEOUT_MS / 60_000}min`)),
|
||||
CYCLE_TIMEOUT_MS
|
||||
)
|
||||
),
|
||||
])
|
||||
)
|
||||
);
|
||||
}),
|
||||
]).finally(() => clearTimeout(timer));
|
||||
})
|
||||
);
|
||||
|
||||
for (let i = 0; i < results.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user