What is the issue or error you’re encountering
I cannot invoke WorkerEntrypoint.
What are the steps to reproduce the issue?
[wrangler.toml]
...
services = [{ binding = "SERVICES", service = "services" }]
...
[index.ts]
import router from './internal/router/router';
export default {
fetch: router.handle,
};
[internal/types/schema.ts]
import { WorkerEntrypoint, RpcTarget } from "cloudflare:workers";
declare class Worker extends RpcTarget {
getProgress(): number;
}
declare class Services extends WorkerEntrypoint {
newWorker(): Worker;
}
export interface Env {
SERVICES: Service<Services>;
}
[internal/router/router.ts]
import { Router } from "itty-router";
import * as schema from '../types/schema';
const router = Router();
router.get('/progress', async (request: Request, env: schema.Env, ctx: ExecutionContext) => {
const worker = await env.SERVICES.newWorker();
const progress = await worker.getProgress();
return new Response(progress);
});
export default router;
- wrangler deploy
- wrangler tail
- curl mydomain/progress
✘ [ERROR] TypeError: env2.SERVICES.newWorker is not a function