Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: treat a backup cron with no next run time as a failed registration (#3910)
[._.]/ Adam Eivy57cc85c727e1
diff --git a/server/services/backupScheduler.js b/server/services/backupScheduler.jsindex e00e1712b2..bf7c7f5843 100644--- a/server/services/backupScheduler.js+++ b/server/services/backupScheduler.js@@ -73,8 +73,9 @@ export async function syncBackupSchedule(settings) {// working timer and throws. Leave `lastSignature` unset in that case so the// next save — even one that re-submits the same value — retries instead of// short-circuiting on a registration that never happened.+ let event;try {- schedule({+ event = schedule({id: EVENT_ID,type: 'cron',cron: inputs.cron,@@ -104,6 +105,18 @@ export async function syncBackupSchedule(settings) {return false;}+ // Not every bad expression throws: a five-field cron with an out-of-range+ // value (`99 1 * * *`) registers with no next run at all. Treat "registered+ // but never fires" as a failure too, so the state cache can't suppress a+ // retry once the user corrects it.+ if (!event?.nextRunAt) {+ cancel(EVENT_ID);+ registered = false;+ lastSignature = null;+ console.error(`❌ Backup scheduler: cron "${inputs.cron}" has no next run time — no backup scheduled`);+ return false;+ }+registered = true;lastSignature = signature;console.log(`💾 Backup scheduler: registered daily backup at cron "${inputs.cron}"`);diff --git a/server/services/backupScheduler.test.js b/server/services/backupScheduler.test.jsindex 08fa3b77ea..98eea96360 100644--- a/server/services/backupScheduler.test.js+++ b/server/services/backupScheduler.test.js@@ -14,7 +14,10 @@import { describe, it, expect, vi, beforeEach } from 'vitest';vi.mock('./eventScheduler.js', () => ({- schedule: vi.fn(),+ // The real schedule() returns the registered event; the scheduler treats a+ // null nextRunAt as a failed registration, so the default mock returns a+ // firing one.+ schedule: vi.fn(() => ({ id: 'backup-daily', nextRunAt: Date.now() + 60_000 })),cancel: vi.fn()}));@@ -217,6 +220,18 @@ describe('settings:updated re-sync', () => {expect(schedule).toHaveBeenCalledTimes(2);});+ it('retries when the cron registered but has no next run time', async () => {+ // An out-of-range five-field expression (`99 1 * * *`) registers without+ // throwing but never fires — that must not be cached as applied.+ getSettings.mockResolvedValue({ backup: { enabled: true, destPath: '/dest', cronExpression: '99 1 * * *' } });+ schedule.mockImplementationOnce(() => ({ id: 'backup-daily', nextRunAt: null }));+ await startBackupScheduler();+ expect(cancel).toHaveBeenCalledWith('backup-daily');++ await emitSettings({ backup: { enabled: true, destPath: '/dest', cronExpression: '99 1 * * *' } });+ expect(schedule).toHaveBeenCalledTimes(2);+ });+it('is a no-op for a save that does not touch backup registration', async () => {getSettings.mockResolvedValue({ backup: { enabled: true, destPath: '/dest' } });await startBackupScheduler();