Skip to content

Fix scheduled trigger execution - #402

Merged
vincentgrobler merged 1 commit into
mainfrom
fix/cron-trigger-execution
Aug 2, 2026
Merged

Fix scheduled trigger execution#402
vincentgrobler merged 1 commit into
mainfrom
fix/cron-trigger-execution

Conversation

@vincentgrobler

@vincentgrobler vincentgrobler commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Problem

Cron and webhook trigger-created agent work could be queued but never executed. The main symptom is scheduled jobs appearing not to fire, even when the trigger configuration is enabled.

Root cause

  • The database pg_cron job only called cron-evaluate every 30 minutes, so normal minute-level cron expressions could be missed.
  • The first-run catch-up path ignored triggers with last_fired_at = null, so a missed first execution could stay missed until the next exact cron minute.
  • Agent cron triggers inserted tasks.status = pending, but claim_next_task only claims dispatched tasks.
  • Cron task creation used agent_id as created_by, but created_by expects a user id.
  • Team cron triggers were selected but not converted into team_runs.
  • Agent webhook triggers had the same pending task-status queue mismatch.

Changes

  • Reschedule evaluate-cron-triggers to run every minute.
  • Use trigger created_at as the first-run catch-up baseline when last_fired_at is null.
  • Create agent trigger tasks as dispatched, with the workspace owner as created_by.
  • Add cron support for team triggers by creating team_runs and waking /webhook/team-run.
  • Keep team runs as pending, matching the existing team-run claim path.
  • Mark trigger-created stuck agent tasks as dispatched in migration 083.
  • Update agent webhook triggers to create executable dispatched tasks.

Deployment notes

After merge:

  1. Apply Supabase migration 083_fix_cron_trigger_execution.sql.
  2. Deploy the updated Supabase Edge Functions, especially cron-evaluate and webhook-trigger.
  3. Deploy/restart the task runner so triggerScheduler.ts changes are active.
  4. Confirm production has the DB settings used by pg_cron:
    • app.settings.supabase_url
    • app.settings.service_role_key
  5. Confirm Edge Function/runtime secrets are configured:
    • TASK_RUNNER_URL
    • WEBHOOK_SECRET

Verification

  • npm run build
  • npm run build from task-runner/
  • git diff --check

Known unrelated issue

npm run lint still fails on an existing landing-page lint error in crewform-landing/src/App.tsx; this PR does not touch that file.

@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
crewform Ready Ready Preview Aug 2, 2026 2:44pm

@vincentgrobler vincentgrobler changed the title Fix cron trigger execution path Fix scheduled trigger execution Aug 2, 2026
@vincentgrobler
vincentgrobler merged commit 9e7d0cc into main Aug 2, 2026
8 checks passed
@vincentgrobler
vincentgrobler deleted the fix/cron-trigger-execution branch August 2, 2026 14:49
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