Wrangler "No event handlers were registered" in CI
Cloudflare found no entry handler in your Worker. A module Worker must export default an object with a fetch (or scheduled, queue) handler; a service-worker Worker must call addEventListener("fetch", ...). Without one, the script does nothing and the deploy is rejected.
What this error means
Deploy fails with "No event handlers were registered. This script does nothing." The bundle built fine, but the exported shape is wrong.
✘ [ERROR] No event handlers were registered. This script does nothing.Common causes
The module has no default export handler
A module-format Worker must default-export an object exposing fetch; a missing or misnamed export leaves no handler.
A bundler tree-shook the handler away
If the entry file only imports side effects, or the wrong file is set as main, the built bundle registers nothing.
How to fix it
Export a default fetch handler
export default {
async fetch(request, env, ctx) {
return new Response("ok");
},
};Point main at the file that exports it
Confirm main in wrangler.toml is the file that actually contains the handler, not an index that re-exports nothing.
main = "src/index.ts"How to prevent it
- Keep the entry module exporting a default
fetchhandler. - Point
mainat the real entry file. - Add a smoke test that imports the module and asserts a handler exists.