Skip to content

Commit 832abd1

Browse files
penalosadaisyfaithauma
authored andcommitted
Clarify testing cron triggers locally (#21942)
1 parent 0ae4e04 commit 832abd1

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/content/docs/workers/configuration/cron-triggers.mdx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ Refer to the following additional examples to write your code:
7171

7272
### 2. Update configuration
7373

74+
:::note[Cron Trigger changes take time to propagate.]
75+
76+
Changes such as adding a new Cron Trigger, updating an old Cron Trigger, or deleting a Cron Trigger may take several minutes (up to 15 minutes) to propagate to the Cloudflare global network.
77+
78+
:::
79+
7480
After you have updated your Worker code to include a `"scheduled"` event, you must update your Worker project configuration.
7581

7682
#### Via the [Wrangler configuration file](/workers/wrangler/configuration/)
@@ -165,24 +171,24 @@ Some common time intervals that may be useful for setting up your Cron Trigger:
165171
- `59 23 LW * *`
166172
- 23:59 (UTC) on the last weekday of the month
167173

168-
## Test Cron Triggers
174+
## Test Cron Triggers locally
169175

170-
The recommended way of testing Cron Triggers is using Wrangler.
171-
172-
:::note[Cron Trigger changes take time to propagate.]
176+
Test Cron Triggers using Wrangler with [`wrangler dev`](/workers/wrangler/commands/#dev). This will expose a `/cdn-cgi/handler/scheduled` route which can be used to test using a HTTP request.
173177

174-
Changes such as adding a new Cron Trigger, updating an old Cron Trigger, or deleting a Cron Trigger may take several minutes (up to 15 minutes) to propagate to the Cloudflare global network.
175-
176-
:::
178+
```sh
179+
curl "http://localhost:8787/cdn-cgi/handler/scheduled"
180+
```
177181

178-
Test Cron Triggers using `Wrangler` by passing in the `--test-scheduled` flag to [`wrangler dev`](/workers/wrangler/commands/#dev). This will expose a `/__scheduled` (or `/cdn-cgi/handler/scheduled` for Python Workers) route which can be used to test using a HTTP request. To simulate different cron patterns, a `cron` query parameter can be passed in.
182+
To simulate different cron patterns, a `cron` query parameter can be passed in.
179183

180184
```sh
181-
npx wrangler dev --test-scheduled
185+
curl "http://localhost:8787/cdn-cgi/handler/scheduled?cron=*+*+*+*+*"
186+
```
182187

183-
curl "http://localhost:8787/__scheduled?cron=*+*+*+*+*"
188+
Optionally, you can also pass a `time` query parameter to override `controller.scheduledTime` in your scheduled event listener.
184189

185-
curl "http://localhost:8787/cdn-cgi/handler/scheduled?cron=*+*+*+*+*" # Python Workers
190+
```sh
191+
curl "http://localhost:8787/cdn-cgi/handler/scheduled?cron=*+*+*+*+*&time=1745856238"
186192
```
187193

188194
## View past events

0 commit comments

Comments
 (0)