Skip to content

feat(flow): scheduled trigger + fix flowsForTrigger (every event trigger was dead) (#2068) - #2126

Merged
rubenvdlinde merged 1 commit into
developmentfrom
feat/flow-scheduled-trigger
Jul 25, 2026
Merged

feat(flow): scheduled trigger + fix flowsForTrigger (every event trigger was dead) (#2068)#2126
rubenvdlinde merged 1 commit into
developmentfrom
feat/flow-scheduled-trigger

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

Run a flow on a schedule — n8n's Schedule/Cron trigger, the last native trigger family — and a fix for a bug this work uncovered: every event trigger was silently firing nothing.

The bug (critical)

OpenRegisterFlowResolver::flowsForTrigger queried findAll(config: ['register'=>…, 'schema'=>…]), but ObjectService::findAll scopes via config['filters']['register'|'schema']. The wrong key returned zero objects, so no flow wired to any event (object/file/user/share/tag) ever matched — triggers queued nothing. The scheduled trigger reuses the same query, which is what surfaced it. Corrected to filters. (HermiqFlowResolver has the identical bug — fixed in its own repo.)

This was never caught before because the earlier trigger verification tested the listener → fire() path, not flowsForTrigger returning ids against the real ObjectService.

The feature

  • FlowScheduleService — lists enabled schedule flows and, for each whose cron occurrence has passed since it last fired, queues a run (trigger schedule) and records the fire time in app config keyed by flow uuid (the flow object is never rewritten). A flow never fired is due at once, then follows its cron.
  • FlowScheduleWorker — a TimedJob (5-min) that ticks the service; scheduled runs are executed by the existing FlowRunWorker, so a scheduled flow shares the whole run lifecycle.
  • The flow schema gains cron; descriptor version bumped so fresh installs ship it.

Verification

  • UnitFlowScheduleServiceTest (6: due fires, recent-not-due, disabled, non-schedule, invalid/missing cron, no store). 154 flow unit tests green; phpcs clean.
  • Playwright e2etests/e2e/api-direct/flow-schedule.spec.ts (2): author a scheduled flow via API → tick the real FlowScheduleWorker via occ background-job:execute → assert a schedule run in history; a non-schedule flow is not fired. All 9 flow e2e pass (7 engine + 2 schedule).
  • Live (8080) — executing the worker queues a schedule run; the findAll fix makes both scheduled and event flows match.

Out of scope

Sub-minute schedules (5-min tick) and per-flow timezone (cron evaluated in the server zone).

🤖 Generated with Claude Code

Run a flow on a schedule — n8n's Schedule/Cron trigger, the last native trigger
family. A flow with trigger `schedule` and a `cron` expression runs when its time
comes, driven by a worker rather than an event.

- FlowScheduleService: given "now", lists the enabled schedule flows and, for
  each whose cron occurrence has passed since it last fired, queues a run
  (trigger `schedule`) and records the fire time in app config keyed by flow uuid
  (so the flow object is never rewritten). A flow never fired is due at once,
  then follows its cron.
- FlowScheduleWorker: a TimedJob (5-min) that asks the service which flows are
  due each tick; scheduled runs are executed by the existing FlowRunWorker, so a
  scheduled flow shares the whole run lifecycle. Registered in info.xml.
- The flow schema gains a `cron` property; the descriptor version is bumped so
  fresh installs ship it.

🔥 FIX — every event trigger was silently dead. OpenRegisterFlowResolver::
flowsForTrigger queried `findAll(config: ['register'=>…, 'schema'=>…])`, but
ObjectService::findAll scopes via `config['filters']['register'|'schema']`. The
wrong key returned ZERO objects, so no flow wired to any event (object/file/user/
share/tag) ever matched — triggers queued nothing. The scheduled trigger, which
reuses the same query, surfaced it. Corrected to `filters`. (HermiqFlowResolver
has the identical bug — fixed in its own repo.)

Tests: FlowScheduleServiceTest (6 — due fires, recent not due, disabled, non-
schedule, invalid/missing cron, no store); 154 flow unit tests green; phpcs
clean. Playwright e2e tests/e2e/api-direct/flow-schedule.spec.ts (2 — a due flow
fired by the worker shows in history; a non-schedule flow is not fired) — all 9
flow e2e pass. Live-verified on 8080: executing the worker queues a schedule run,
and the findAll fix makes both scheduled and event flows match.
@rubenvdlinde
rubenvdlinde merged commit c20b9d9 into development Jul 25, 2026
15 of 17 checks passed
@rubenvdlinde
rubenvdlinde deleted the feat/flow-scheduled-trigger branch July 25, 2026 20:53
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ 0db0863

Check PHP Vue Security License Tests
lint
phpcs
phpmd
psalm
phpstan
phpmetrics
eslint
stylelint
composer ✅ 174/174
npm ✅ 555/555
PHPUnit
Newman
Playwright ⏭️

Quality workflow — 2026-07-25 21:01 UTC

Download the full PDF report from the workflow artifacts.

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