Skip to content

[wrangler] Add schedule property to Workflow bindings for cron-based triggering - #13467

Merged
pombosilva merged 4 commits into
mainfrom
WOR-1221-workflow-schedule
May 21, 2026
Merged

[wrangler] Add schedule property to Workflow bindings for cron-based triggering#13467
pombosilva merged 4 commits into
mainfrom
WOR-1221-workflow-schedule

Conversation

@deloreyj

@deloreyj deloreyj commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Fixes WOR-1221.

Add an optional schedule field to Workflow bindings that accepts a cron expression string or array of cron expressions. On wrangler deploy, the schedule is sent to the Workflows control plane API, enabling automatic triggering of workflow instances on a cron schedule.

NOTE: This is a configuration-only change. Scheduled triggering of Workflow instances is not yet available - adding schedule to a Workflow binding will not result in scheduled invocations at this time. This change lays the groundwork for an upcoming feature.

Changes

  • Added schedule?: string | string[] to WorkflowBinding type and CfWorkflow interface
  • Added validation in validateWorkflowBinding — accepts a non-empty string or non-empty array of non-empty strings; errors on wrong type, empty string, empty array, or mixed array
  • Added schedule to the API payload in triggers/deploy.ts, with an error if schedule is configured on a workflow that references an external script_name (consistent with how limits is handled)

Usage

// wrangler.json
{
  "workflows": [
    {
      "binding": "MY_WORKFLOW",
      "name": "my-workflow",
      "class_name": "MyWorkflow",
      "schedule": "0 9 * * 1"
    }
  ]
}

Multiple schedules:

{
  "workflows": [
    {
      "binding": "MY_WORKFLOW",
      "name": "my-workflow",
      "class_name": "MyWorkflow",
      "schedule": ["0 9 * * 1", "0 17 * * 5"]
    }
  ]
}

A picture of a cute animal (not mandatory, but encouraged)

@changeset-bot

changeset-bot Bot commented Apr 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7d189a6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
wrangler Minor
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Apr 14, 2026
@workers-devprod
workers-devprod requested review from a team and jamesopstad and removed request for a team April 14, 2026 09:50
@workers-devprod

workers-devprod commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/workers-utils/src/config/environment.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/config/validation.ts: [@cloudflare/wrangler]
  • packages/workers-utils/src/worker.ts: [@cloudflare/wrangler]
  • packages/workers-utils/tests/config/validation/normalize-and-validate-config.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/deploy/workflows.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/dev/miniflare/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/triggers/deploy.ts: [@cloudflare/wrangler]

@github-actions

github-actions Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

✅ All changesets look good

ask-bonk[bot]

This comment was marked as resolved.

@ask-bonk

ask-bonk Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

I'm Bonk, and I've done a quick review of your PR.

This PR adds an optional schedule field (string or string[]) to Workflow bindings, validated at config time and sent to the Workflows API on deploy. The implementation is clean and follows the existing patterns for limits well.

I found one actionable issue and posted it as a review:

  1. Empty array passes validation and gets sent to the APIschedule: [] passes the .every() check vacuously, and [] is truthy in JS, so it would be serialized as { schedule: [] } in the API request. Similarly [""] passes. I posted a suggestion to add length > 0 and empty-string checks in the validation.

github run

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Apr 14, 2026

Copy link
Copy Markdown
create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@13467

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@13467

miniflare

npm i https://pkg.pr.new/miniflare@13467

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@13467

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@13467

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@13467

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@13467

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@13467

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@13467

wrangler

npm i https://pkg.pr.new/wrangler@13467

commit: 3f5388a

devin-ai-integration[bot]

This comment was marked as resolved.

@petebacondarwin

Copy link
Copy Markdown
Contributor

Hi @deloreyj — we're doing some cleanup of stale draft PRs.

This PR has been quiet since 2026-04-16. Could you let us know within 14 days whether you're still planning to continue?

  • If yes: please leave a comment with a status update or push a rebase, and we'll keep it open.
  • If no: no need to reply — we'll close it after 14 days, and you can always reopen later if you pick it back up.

Thanks!

@pombosilva
pombosilva force-pushed the WOR-1221-workflow-schedule branch 2 times, most recently from a9eb8ce to 7d189a6 Compare May 20, 2026 12:04
@pombosilva
pombosilva marked this pull request as ready for review May 20, 2026 12:06
@workers-devprod
workers-devprod requested review from a team and petebacondarwin and removed request for a team May 20, 2026 12:07
@workers-devprod

workers-devprod commented May 20, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@petebacondarwin petebacondarwin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that workerd already implements this and that it gets picked up and works for local development in Miniflare automatically?

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk May 20, 2026
deloreyj added 2 commits May 21, 2026 14:47
…triggering

Add optional schedule field to WorkflowBinding and CfWorkflow types, accepting a
cron expression string or array of cron expressions. The schedule is validated on
config load and sent to the Workflows control plane API on deploy. Configuring
schedule on a workflow that references an external script_name is an error.

WOR-1221
@pombosilva
pombosilva force-pushed the WOR-1221-workflow-schedule branch from 7d189a6 to 3f5388a Compare May 21, 2026 13:48
@pombosilva
pombosilva enabled auto-merge (squash) May 21, 2026 13:52
@pombosilva
pombosilva merged commit 3a1fbed into main May 21, 2026
61 of 63 checks passed
@pombosilva
pombosilva deleted the WOR-1221-workflow-schedule branch May 21, 2026 14:25
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk May 21, 2026
penalosa pushed a commit that referenced this pull request May 28, 2026
…triggering (#13467)

Co-authored-by: Olga Silva <osilva@cloudflare.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants