a restart mid-sync stranded accounts at syncing or queued forever
getAllSyncedAccounts only picks up status = synced, so an account whose sidecar process died between marking it syncing/queued and clearing that status again dropped out of the cron and the IDLE watcher silently, with no error to explain why background sync had stopped. Reset both on startup instead: the job runner is in-memory, so neither state can be genuinely in flight in a fresh process.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { getUserById } from 'officerdb';
|
||||
import { getAllSyncedAccounts } from '../db/queries';
|
||||
import { getAllSyncedAccounts, resetStuckSyncingAccounts } from '../db/queries';
|
||||
import { performResync } from './resync';
|
||||
|
||||
const INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
|
||||
@@ -32,6 +32,9 @@ async function tick() {
|
||||
|
||||
export function initEmailCron() {
|
||||
if (timer) return;
|
||||
resetStuckSyncingAccounts().catch((err) => {
|
||||
console.error('[email-cron] Failed to reset stuck accounts:', err instanceof Error ? err.message : err);
|
||||
});
|
||||
console.log(`[email-cron] Starting email sync cron (every ${INTERVAL_MS / 60_000} min)`);
|
||||
timer = setInterval(tick, INTERVAL_MS);
|
||||
setTimeout(tick, 30_000);
|
||||
|
||||
Reference in New Issue
Block a user