-
Notifications
You must be signed in to change notification settings - Fork 736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support cron triggers using preview and dev #570
Comments
Thanks for making this issue! This is definitely something we need to support. In the interim, a simple workaround would be to call a mock scheduled event from a fetch handler. Not nice, but it can get the job done for you if you need it today. |
Cloudflare recently released miniflare, which supports cron trigger testing. If anyone wants to test cron triggers at the moment, you may refer this link https://miniflare.dev/scheduled.html Of cause, cron trigger support for |
Copy pasting from #738 (comment), where we're landing support for local mode soon.
|
Using the new middleware (#1735), we implement a way of testing scheduled workers from a fetch using `wrangler dev` in remote mode, by passing a new command line flag `--test-scheduled`. This exposes a route `/__scheduled` which will trigger the scheduled event. ```sh $ npx wrangler dev index.js --test-scheduled $ curl http://localhost:8787/__scheduled ``` Closes #570
Miniflare 3 no longer includes a CLI. We're encouraging people to use Wrangler instead. Closes DEVX-627
Miniflare 3 no longer includes a CLI. We're encouraging people to use Wrangler instead. Closes DEVX-627
Miniflare 3 no longer includes a CLI. We're encouraging people to use Wrangler instead. Closes DEVX-627
Miniflare 3 no longer includes a CLI. We're encouraging people to use Wrangler instead. Closes DEVX-627
💡 Feature request
Describe the feature
Currently, there is no way to test scheduled jobs, since we can't fire a
scheduled
during development. I suggest adding support of "cron triggers testing" forwrangler dev
orwrangler preview
, which speeds up the development and testing.Possible methods of triggering a cron job during development:
wrangler dev
, wrangler creates a special route (path) during development, and developers can trigger a job by sending a request to the route, eg:GET http://127.0.0.1:8787/__crons/:cronExpression
wrangler preview
, aTest Triggers
tab is available for developers to trigger a cron job.Describe the alternatives
The current work around for this issue is to simply deploy the worker to production.
Or add the code I want to test to the
fetch
event handler, which is really inconvenient:Thanks.
The text was updated successfully, but these errors were encountered: