Problem
Currently, if any single DB query fails in loadSchedules() (e.g., the alarmSchedules query), the entire load aborts. This leaves the scheduler in a partially initialized state where some job types are scheduled but others are missing, with no clear indication to the caller.
File: src/scheduler/jobManager.ts:70-111
Impact
- Development: Fail-fast behavior makes debugging easier
- Production: Single table failure could prevent ALL schedules from loading
Proposed Solution
Wrap each schedule type section in its own try/catch:
async loadSchedules(): Promise<void> {
console.log('Loading schedules from database...')
// Temperature schedules
try {
const tempSchedules = await db.select().from(temperatureSchedules)
for (const sched of tempSchedules) {
if (sched.enabled) {
this.scheduleTemperature(sched)
}
}
} catch (error) {
console.error('Failed to load temperature schedules:', error)
}
// Repeat for power, alarm, and system schedules...
console.log(`Loaded ${this.scheduler.getJobs().length} scheduled jobs`)
}
Priority
Medium - Should be implemented before production deployment for better resilience
References
Problem
Currently, if any single DB query fails in
loadSchedules()(e.g., thealarmSchedulesquery), the entire load aborts. This leaves the scheduler in a partially initialized state where some job types are scheduled but others are missing, with no clear indication to the caller.File:
src/scheduler/jobManager.ts:70-111Impact
Proposed Solution
Wrap each schedule type section in its own try/catch:
Priority
Medium - Should be implemented before production deployment for better resilience
References