Can you create infinite workflows with hooks and for await?
This post might have stale content, as HEAD is 1010 commits ahead.
you can create infinite workflows, using hooks + for await ..., right?
is that pattern recommended? it's pretty cool, the only thing i worry about is related to error handling and retries: if a step fails, it can't be skipped, right?
what about this?
export async function infiniteWorkflow() {
"use workflow";
const hook = createHook<{ message: string }>();
for await (const payload of hook) {
// This loop runs indefinitely, receiving events one by one
await processMessage(payload.message).catch(e => {
if (e instanceof FatalError) {
return
} else {
throw e
}
});
if (payload.message === "stop") {
break; // Only way to exit
}
}
}
END OF POST