Simple RPC between 2 workers results in `Unknown Event - Canceled @...`

Here's what I'm working with: Here's a sample of the RPC WORKER
// wrangler.toml
name = "cfw-utils"
main = "src/index.ts"
compatibility_date = "2024-04-04"
compatibility_flags = ["nodejs_compat"]
...

// index.ts
export default class extends WorkerEntrypoint<Env> {
async fetch() {
return new Response('Not Authorized', { status: 401 });
}

async getThing(thingId: string) {
this.ctx.passThroughOnException();
const result = await getThingFromDb(this.env.DB, thingId);
return new Response(JSON.stringify(result));
}
}
// wrangler.toml
name = "cfw-utils"
main = "src/index.ts"
compatibility_date = "2024-04-04"
compatibility_flags = ["nodejs_compat"]
...

// index.ts
export default class extends WorkerEntrypoint<Env> {
async fetch() {
return new Response('Not Authorized', { status: 401 });
}

async getThing(thingId: string) {
this.ctx.passThroughOnException();
const result = await getThingFromDb(this.env.DB, thingId);
return new Response(JSON.stringify(result));
}
}
I'll call this CONSUMER
// wrangler.toml
services = [
{ binding = "CFW_UTILS", service = "cfw-utils"}
]

// index.ts
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
// ...
const result = await env.CFW_UTILS.getThing(thingId)
.then((thing: string) => {
console.log('(rpc) thing ', thing);
return thing;
})
.catch((err: Error) => {
console.log('(rpc) error ', err);
return 'error occurred getting thing.';
});
// ...
}
}
// wrangler.toml
services = [
{ binding = "CFW_UTILS", service = "cfw-utils"}
]

// index.ts
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
// ...
const result = await env.CFW_UTILS.getThing(thingId)
.then((thing: string) => {
console.log('(rpc) thing ', thing);
return thing;
})
.catch((err: Error) => {
console.log('(rpc) error ', err);
return 'error occurred getting thing.';
});
// ...
}
}
Wrangler tail for BOTH of these shows a
Unknown Event - Canceled @ 4/5/2024, 5:49:01 PM
Unknown Event - Canceled @ 4/5/2024, 5:49:01 PM
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server