Skip to content

refactor: wrap ScheduleExecutor handleMissedRun in transaction #83

@dean0x

Description

@dean0x

Summary

ScheduleExecutor.handleMissedRun() performs two separate database operations without transaction protection. If the first succeeds but the second fails, the schedule is cancelled with no audit trail.

Affected Code

File: src/services/schedule-executor.ts (lines 385-415)

Two sequential operations:

  1. scheduleRepo.update() — cancels the schedule
  2. scheduleRepo.recordExecution() — records the failed execution audit trail

If step 1 succeeds but step 2 fails, the schedule is cancelled with no audit record explaining why.

Proposed Fix

Inject Database into ScheduleExecutor (same pattern used in ScheduleHandler from #81) and wrap both calls in database.runInTransaction() using the sync variants (updateSync, recordExecutionSync).

Risk

Low — both operations target the same entity type and the audit trail gap is cosmetic.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtTechnical debt items tracked for future cleanup

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions