Luca (steebchen)
Luca (steebchen)
Explore posts from servers
CDCloudflare Developers
Created by Luca (steebchen) on 1/12/2025 in #workers-help
Weird "run" error with workers + CF workflows
ah alright. thx!
4 replies
CDCloudflare Developers
Created by Luca (steebchen) on 1/13/2025 in #workflows-beta
I'm getting this error with the
ah perfect thank you for this!
3 replies
CDCloudflare Developers
Created by Luca (steebchen) on 1/12/2025 in #workers-help
Weird "run" error with workers + CF workflows
No description
4 replies
CDCloudflare Developers
Created by Luca (steebchen) on 1/13/2025 in #workflows-beta
I'm getting this error with the
gotcha thx
3 replies
CDCloudflare Developers
Created by Luca (steebchen) on 1/12/2025 in #workers-help
Weird "run" error with workers + CF workflows
my wrangler.toml
[[workflows]]
# name of your workflow
name = "telegram-mod-wf"
# binding name env.MY_WORKFLOW
binding = "workflow"
# this is class that extends the Workflow class in src/index.ts
class_name = "MessageHandler"
[[workflows]]
# name of your workflow
name = "telegram-mod-wf"
# binding name env.MY_WORKFLOW
binding = "workflow"
# this is class that extends the Workflow class in src/index.ts
class_name = "MessageHandler"
4 replies
CDCloudflare Developers
Created by Luca (steebchen) on 1/13/2025 in #workflows-beta
I'm getting this error with the
my (vi)test file (it's almost the same as the default)
// test/index.spec.ts
import {
createExecutionContext,
env,
SELF,
waitOnExecutionContext,
} from "cloudflare:test";
import { describe, expect, it } from "vitest";

import worker from "../src/index";

const IncomingRequest = Request<unknown, IncomingRequestCfProperties>;

describe("Hello World worker", () => {
it("responds with Hello World! (unit style)", async () => {
const request = new IncomingRequest("http://example.com");
// Create an empty context to pass to `worker.fetch()`.
const ctx = createExecutionContext();
const response = await worker.fetch(request, env as any, ctx);
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
await waitOnExecutionContext(ctx);
expect(await response.text()).toMatchInlineSnapshot(`"Not found"`);
});

it("responds with Hello World! (integration style)", async () => {
const response = await SELF.fetch("https://example.com");
expect(await response.text()).toMatchInlineSnapshot(`"Not found"`);
});
});
// test/index.spec.ts
import {
createExecutionContext,
env,
SELF,
waitOnExecutionContext,
} from "cloudflare:test";
import { describe, expect, it } from "vitest";

import worker from "../src/index";

const IncomingRequest = Request<unknown, IncomingRequestCfProperties>;

describe("Hello World worker", () => {
it("responds with Hello World! (unit style)", async () => {
const request = new IncomingRequest("http://example.com");
// Create an empty context to pass to `worker.fetch()`.
const ctx = createExecutionContext();
const response = await worker.fetch(request, env as any, ctx);
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
await waitOnExecutionContext(ctx);
expect(await response.text()).toMatchInlineSnapshot(`"Not found"`);
});

it("responds with Hello World! (integration style)", async () => {
const response = await SELF.fetch("https://example.com");
expect(await response.text()).toMatchInlineSnapshot(`"Not found"`);
});
});
my index file
export class MessageHandler extends WorkflowEntrypoint<Env, Queue> {
public async run(event: WorkflowEvent<Queue>, step: WorkflowStep) {
// ...
}
}

export default {
async fetch(request, env, _ctx): Promise<Response> {
if (request.method === "GET") {
return new Response("Not found", { status: 404 });
}
}
}
export class MessageHandler extends WorkflowEntrypoint<Env, Queue> {
public async run(event: WorkflowEvent<Queue>, step: WorkflowStep) {
// ...
}
}

export default {
async fetch(request, env, _ctx): Promise<Response> {
if (request.method === "GET") {
return new Response("Not found", { status: 404 });
}
}
}
3 replies