← Today I learned

Two Cloudflare Workers gotchas from one weekend

Building a few small Workers for this site turned up two things the docs don't shout about.

1. Named exports in your entry file are treated as entrypoints. I added export const SYSTEM_PROMPT = … to a Worker's main module so a test script could import it. Deploys went fine, but wrangler dev refused to start:

Incorrect type for map entry 'SYSTEM_PROMPT': the provided value is not of
type 'function or ExportedHandler'

The runtime treats every export of the main module as a handler or Durable Object class. Move shared constants into their own module and import them.

2. Cron triggers need a workers.dev subdomain, even if your Worker only runs on your own domain with workers_dev: false:

You need a workers.dev subdomain in order to proceed. [code: 10063]

Even an empty "crons": [] calls that API. I didn't want one, so I dropped the scheduled cleanup and purge expired rows on read instead.