Skip to content

fix: prevent task.next event loop on todo task updates#23

Merged
danielkov merged 2 commits intomainfrom
fix/task-next-event-loop
Feb 22, 2026
Merged

fix: prevent task.next event loop on todo task updates#23
danielkov merged 2 commits intomainfrom
fix/task-next-event-loop

Conversation

@danielkov
Copy link
Copy Markdown
Collaborator

Fix task.next event loop on todo task updates

Workers subscribing to task.next events experienced an event loop where the same task would emit repeated task.next events approximately every second. This caused unnecessary event spam and wasted runner capacity.

Root cause: The trg_task_next_on_status_todo trigger fired on any update to a task with status = 'todo', not just on transitions to todo. When a worker claimed a task (setting owner, worker_ids, etc.), the update triggered another task.next event, which the daemon dispatched back to a worker, creating an infinite loop at the poll interval.

What changed:

  • Added AND OLD.status != 'todo' guard to trg_task_next_on_status_todo, so it only fires on actual status transitions to todo — not on metadata updates to tasks already in todo status
  • Added e2e tests verifying that owner/worker updates on todo tasks don't re-emit task.next
  • Added full lifecycle test covering project dependency cascade through worker-style updates

✻ Clauded...

danielkov and others added 2 commits February 22, 2026 19:37
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The prior commit edited an existing migration in-place, which won't
apply to databases that already ran it (SQLx tracks checksums). Revert
the original migration and add a new one that drops/recreates the
trigger with the OLD.status != 'todo' guard.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@danielkov danielkov merged commit 0ca9f80 into main Feb 22, 2026
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.

1 participant