Skip to content

fix(engine): defensive cleanup for orphaned scheduled actions#783

Merged
chubes4 merged 1 commit intoExtra-Chill:mainfrom
saraichinwag:fix/orphaned-scheduled-actions-cleanup
Mar 11, 2026
Merged

fix(engine): defensive cleanup for orphaned scheduled actions#783
chubes4 merged 1 commit intoExtra-Chill:mainfrom
saraichinwag:fix/orphaned-scheduled-actions-cleanup

Conversation

@saraichinwag
Copy link
Contributor

Problem

Flows deleted without proper Action Scheduler cleanup leave behind orphaned scheduled actions that fire repeatedly, causing "Flow not found" errors every 6 hours.

Solution

Adds a defensive guard in the datamachine_run_flow_now action hook that:

  1. Checks if the flow exists before attempting execution
  2. Auto-cancels orphaned scheduled actions with a warning log
  3. Returns early to prevent unnecessary error noise

Changes

  • New datamachine_flow_exists() helper for lightweight flow lookup
  • Updated datamachine_run_flow_now hook with defensive early-return
  • Cleanup events logged for observability

Testing

  • Verified orphaned Flow 10 actions were cancelled
  • Confirmed no pending actions reference non-existent flows
  • PHP syntax check passed

Fixes recurring "Flow not found" errors from historical cruft or edge case deletions.

Adds a guard in the datamachine_run_flow_now action hook that checks
if the flow exists before attempting execution. If the flow was deleted
without cleaning up its Action Scheduler actions (historical cruft or
edge cases), the orphaned actions are automatically cancelled with a
warning log entry.

This prevents recurring 'Flow not found' errors every time an orphaned
scheduled action fires.

- Adds datamachine_flow_exists() helper for lightweight flow lookup
- Updates datamachine_run_flow_now hook with defensive early-return
- Logs cleanup events for observability
@chubes4 chubes4 merged commit df64fca into Extra-Chill:main Mar 11, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants