Scheduled Worker (Cron Trigger) default Example fails?

If I try to follow the guide and do npm create cloudflare@latest and select Scheduled Worker (Cron Trigger) everything seems to work, I login with wrangler and it deploys, but then it gets stuck waiting for deployment to become available. When I go and look at the logs in the deployed default worker I see:
"exceptions": [
{
"name": "Error",
"message": "Handler does not export a fetch() function.",
"timestamp": 1701233459526
}
"exceptions": [
{
"name": "Error",
"message": "Handler does not export a fetch() function.",
"timestamp": 1701233459526
}
Its not a great experience for onboarding devs 😢 Can someone take a look at it?
6 Replies
Cyb3r-Jak3
Cyb3r-Jak3•13mo ago
Do you have the workers dev domain off? If it is on then I would expect to see those errors as bots scrape the certificate list and will find your worker and spam requests to it. On a cron worker, you’d see that error in the logs
AndrewMohawk
AndrewMohawkOP•13mo ago
I havent adjusted any settings, literally just followed the prompts from npm create so its deploying to the workers.dev domain
Cyb3r-Jak3
Cyb3r-Jak3•13mo ago
Then yeah you probably have the workers dev domain enabled. Add workers_dev = false to your wrangler config and redeploy. You shouldn’t see any more errors after
AndrewMohawk
AndrewMohawkOP•13mo ago
thnx Its the default example, so I assumed out the box it would work
Cyb3r-Jak3
Cyb3r-Jak3•13mo ago
It does work out of the box. But maybe an issue should be opened on the workers-sdk repo to have the workers dev domain disabled on cron template.
AndrewMohawk
AndrewMohawkOP•13mo ago
I actually cant find the example page, I understand what you are saying, maybe I just missed the text that said wait for the trigger, I would assume there would be a default export that gives a response to indicate it I guess
Want results from more Discord servers?
Add your server