The error, verbatim
Jump to the fix ↓X [ERROR] A request to the Cloudflare API (/accounts/.../workers/scripts/nk-repro-cpu) failed.
The uploaded script has no registered event handlers. Please visit the following website for more information: https://developers.cloudflare.com/workers/runtime-apis/handlers/. [code: 10068]
# a Worker file with no export at all:
No event handlers were registered. This script does nothing.
[code: 10021]
The fix that worked
Export the handler as the default export:
export default {
async fetch(request) {
return new Response('hello');
},
};Not it? Every cause, tested ↓Tested on
- wrangler
- 4.139.0 (deploys), 4.156.0 (wrangler dev)
- Worker
- compatibility_date 2026-09-01
- Hono
- 4.x
- OS
- Windows 11 Pro; Ubuntu on GitHub Actions
✓ Last re-run on GitHub Actions · see the run · all repros
Contents
Cloudflare checks every upload for at least one handler it can call, such as fetch. If it can’t find one, wrangler deploy stops. The catch is that it only recognises handlers written a specific way, and one common mistake passes the check and fails later, for every visitor.
The fix
Export your handler as the default export, as an object with a fetch method:
export default {
async fetch(request) {
return new Response('hello');
},
};If your Worker uses the older service-worker style, the event name has to be exactly fetch:
addEventListener('fetch', (event) => {
event.respondWith(new Response('hello'));
});Three ways it goes wrong
I deployed each of these to a real test Worker with wrangler 4.139.0:
| The file | What happened |
|---|---|
addEventListener('fecth', …), one letter swapped |
rejected: The uploaded script has no registered event handlers [code: 10068] |
a fetch function that’s never exported |
rejected: No event handlers were registered. This script does nothing. [code: 10021] |
export async function fetch(request) { … } |
deployed, then every request got a 404 |
The last one is the nasty one. A named export called fetch isn’t a handler, only the default export is, but the upload goes through with no warning. Visiting the Worker then shows Cloudflare’s placeholder page with HTTP 404:
Page not found
There is nothing here yet
If you expect something to be here, it may take some time.
Please check back again later.
What wrangler dev shows for the same mistakes
Locally the errors look different, and the worst case is silent. I ran each handler shape under wrangler dev (wrangler 4.156.0, local workerd) and requested /:
| The file | wrangler dev |
|---|---|
export default { async fetch() { … } } |
✅ HTTP 200 hello |
export async function fetch() { … } (named export) |
prints Ready on http://localhost:8799, then the request never gets an answer (no error in the log, curl gave up after 20 s) |
export default async function (request) { … } (a plain function) |
❌ the runtime doesn’t start: Uncaught TypeError: Class extends value async function src_default(request) {… |
module.exports = { async fetch() { … } } (CommonJS) |
❌ the runtime doesn’t start: Uncaught ReferenceError: module is not defined |
addEventListener('fecth', …) |
starts, then every request fails with HTTP 500 Error: No response! |
So a request that hangs in wrangler dev with a clean log usually means a named fetch export: the same file that deploys and serves the 404 page above. And if the startup error mentions Class extends value, your default export is a bare function.
Wrap it in an object:
export default {
fetch: handler, // your existing async function (request, env, ctx)
};Both errors stop the local runtime with this line after them, which sounds like a broken install but isn’t:
✘ [ERROR] The Workers runtime failed to start. There was likely a problem with the workerd binary or your configuration.
Using Hono (or another router)
A Hono app is already a valid default export, because the app object has a fetch method. Both of these answered HTTP 200 hello under wrangler dev:
import { Hono } from "hono";
const app = new Hono();
app.get("/", (c) => c.text("hello"));
export default app;
// or, the same thing spelled out:
// export default { fetch: app.fetch };
How this was tested
Five small Worker files deployed to one test Worker on workers.dev with wrangler 4.139.0 and compatibility_date 2026-09-01: a misspelled addEventListener, an unexported fetch, a named fetch export, a default export, and a correct addEventListener('fetch'). The rejections are copied from wrangler’s output, and the 404 page and the hello responses from requests to the deployed Worker. When a Worker already runs, a rejected upload leaves it running the previous version.
November 1, 2026: seven handler shapes (the five above plus a default-exported plain function, CommonJS module.exports, and Hono both ways) ran under wrangler dev with wrangler 4.156.0 on GitHub Actions ubuntu-latest, each answering one request to /. The plain-function and CommonJS shapes were tested locally only, not deployed. The script and the full output are public.
— N.K., end of entry No.032