Skip to content

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

Draft
deloreyj wants to merge 3 commits intomainfrom
WOR-1221-workflow-schedule
Draft

[wrangler] Add schedule property to Workflow bindings for cron-based triggering#13467
deloreyj wants to merge 3 commits intomainfrom
WOR-1221-workflow-schedule

Conversation

@deloreyj
Copy link
Copy Markdown

@deloreyj deloreyj commented Apr 14, 2026

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.

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)

…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
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 14, 2026

🦋 Changeset detected

Latest commit: c99475c

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

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
Copy link
Copy Markdown
Contributor

workers-devprod commented Apr 14, 2026

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
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

✅ All changesets look good

ask-bonk[bot]

This comment was marked as resolved.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Apr 14, 2026

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

Copy link
Copy Markdown
Contributor

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

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
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 14, 2026

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

wrangler

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

commit: c99475c

devin-ai-integration[bot]

This comment was marked as resolved.

@deloreyj deloreyj marked this pull request as draft April 16, 2026 09:59
@jamesopstad jamesopstad removed their request for review April 16, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants