Access to KV from `wrangler dev` to test Cron Worker

Setting up a Cron Worker for the first time, long time Workers user. I have my bindings setup properly in my wrangler.toml file, but when I try and access a KV from my Cron Worker, scheduler code, I get undefined. I am running this via wrangler dev and have read that this has a lot of issues and doesn't really replicate prod. Can anyone confirm or deny? If you can't access and test those locally, how do you debug Cron Workers that use KV without constantly deploying them.
1 Reply
Mackenly
Mackenly7mo ago
I'm sure there are some bugs sometimes in wrangler but for the most part it's very solid. Some things like AI aren't able to run locally (for obvious reasons) so need to be ran remote, but otherwise wrangler should be doing a good job. I would suggest using the
--test-scheduled
--test-scheduled
flag like described here to test and debug scheduled crons: https://developers.cloudflare.com/workers/runtime-apis/handlers/scheduled/
Scheduled Handler · Cloudflare Workers docs
When a Worker is invoked via a Cron Trigger, the scheduled() handler handles the invocation.