Jani
Jani
CDCloudflare Developers
Created by Jani on 10/29/2024 in #workflows-beta
I’ve been testing out long-running
Thanks for getting back to me
10 replies
CDCloudflare Developers
Created by Jani on 10/29/2024 in #workflows-beta
I’ve been testing out long-running
Ahh ok makes sense
10 replies
CDCloudflare Developers
Created by Jani on 10/29/2024 in #workflows-beta
I’ve been testing out long-running
Good to know, definitely seemed like a bug.
10 replies
CDCloudflare Developers
Created by Jani on 10/29/2024 in #workflows-beta
I’ve been testing out long-running
The updated workflow reduced the sleep cycle to 1min - that should explain different start & end times above
10 replies
CDCloudflare Developers
Created by Jani on 10/29/2024 in #workflows-beta
I’ve been testing out long-running
No description
10 replies
CDCloudflare Developers
Created by Jani on 10/29/2024 in #workflows-beta
I’ve been testing out long-running
Workflow (based on workflows-starter):
type State = {
lastExecution: number;
count: number;
};

export class TestWorkflow extends WorkflowEntrypoint<Env, Params> {
override async run(_event: WorkflowEvent<Params>, step: WorkflowStep) {
let state: State | undefined = undefined;
while (true) {
state = await step.do('do something', async () => {
const result = {
lastExecution: Date.now(),
count: (state?.count ?? 0) + 1,
};
console.log(result);
return result;
});

if (state.count >= 10) {
break;
}

await step.sleep('sleep', '30 minutes');
}
return state;
}
}
type State = {
lastExecution: number;
count: number;
};

export class TestWorkflow extends WorkflowEntrypoint<Env, Params> {
override async run(_event: WorkflowEvent<Params>, step: WorkflowStep) {
let state: State | undefined = undefined;
while (true) {
state = await step.do('do something', async () => {
const result = {
lastExecution: Date.now(),
count: (state?.count ?? 0) + 1,
};
console.log(result);
return result;
});

if (state.count >= 10) {
break;
}

await step.sleep('sleep', '30 minutes');
}
return state;
}
}
10 replies