steyblind
steyblind
CDCloudflare Developers
Created by steyblind on 8/9/2024 in #workers-help
puzzling waitUntil warning
No description
6 replies
CDCloudflare Developers
Created by steyblind on 4/5/2024 in #workers-help
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
1 replies
CDCloudflare Developers
Created by steyblind on 1/29/2024 in #workers-help
best practice for composing workers?
Is there a solution like CDK (https://aws.amazon.com/cdk/) for managing workers and config? What’s the best practice for managing dozens (hundreds) or workers and services?
3 replies
CDCloudflare Developers
Created by steyblind on 11/18/2023 in #workers-help
Tail fails + Log Stream fails on socket error
No description
6 replies