"Handler does not export a scheduled() function" - No matter how it's exported
Howdy,
I'm struggling to use the CRON events for my worker; no matter how I export my
scheduled
fnc, the worker insists it does not exist.
As I understand it, the export must be named exactly scheduled
, so in my index.ts
I have the following:
Yet when the CRON runs, I get Handler does not export a scheduled() function
.
If I try using export default
then I get errors about the handler not having fetch
.
If I used a named export for fetch
and the default
for what would be the scheduled
, I get a different error again: No event listener registered for scheduled events.
.
I feel I'm running in circles lol, any input would be appreciated, thanks.8 Replies
I believe it needs to be the default export
https://developers.cloudflare.com/workers/runtime-apis/handlers/scheduled/#syntax
Cloudflare Docs
Scheduled Handler · Cloudflare Workers docs
When a Worker is invoked via a Cron Trigger, the scheduled() handler handles the invocation.
If I try using export default then I get errors about the handler not having fetch.:NotLikeThis: Any suggestions? 😅 I'll try it again now and get the full error
Oh sorry it is late
Ahhh okay, I hadn't tried that, allow me a moment to edit, deploy, and CRON to test, ty! :pray_duck:
:pogfish:

I've been stuck on this for over 4 hours and you solved it in 2 messages, my hero
Glad it was a quick fix.
:Prayge:
May your pillow always be cold, ty, good evening