Are event handlers necessary for RPC?

Are event handlers now necessary? I have workers I don't want to expose to fetch and only want to invoke via RPC. Why cant I do something like:
import { WorkerEntrypoint } from "cloudflare:workers";

export default class extends WorkerEntrypoint {
async add(a: number, b: number) {
return a + b;
}
}
import { WorkerEntrypoint } from "cloudflare:workers";

export default class extends WorkerEntrypoint {
async add(a: number, b: number) {
return a + b;
}
}
without getting this error: The uploaded script has no registered event handlers. Please visit the following website for more information:
2 Replies
texan
texanthis hour
Yup, Workers expects a handler, even if you only want to invoke it via RPC. Workers need a defined way to process incoming requests.
darkpool
darkpoolOP23h ago
thanks @Will Taylor | Workers !

Did you find this page helpful?