Steps that remember
Wrap work in step.do(). After a sleep, a retry or a crash, finished steps return their saved results and the workflow carries on.
Sign-up flows, order fulfilment, billing runs and AI pipelines as plain JavaScript. Each stepβs result is saved, steps retry with backoff, and a workflow can sleep for days or wait for a payment or an approval. Nothing runs, and nothing is billed, while it waits.
// lyrcloud.json: "workflows": { "ORDERS": "orders" }, "email": "EMAIL"
export default {
async fetch(request, env) {
const run = await env.ORDERS.create({ params: await request.json() });
return Response.json({ id: run.id });
},
workflows: {
async orders(event, step, env) {
const order = await step.do('charge card', { retries: { limit: 5, delay: '30 seconds' } },
() => chargeCard(event.payload));
await step.sleep('let the warehouse pack it', '2 hours');
const shipped = await step.waitForEvent('shipped', { type: 'shipped', timeout: '7 days' });
await step.do('email the customer', () => env.EMAIL.send({
from: 'Shop <orders@example.com>', to: order.email,
subject: 'On its way!', text: `Tracking: ${shipped.payload.tracking}`,
}));
return { tracking: shipped.payload.tracking };
},
},
};
// $ lyrcloud workflows event orders <id> shipped --payload '{"tracking":"1Zβ¦"}'
Wrap work in step.do(). After a sleep, a retry or a crash, finished steps return their saved results and the workflow carries on.
Set a limit, a delay and constant, linear or exponential backoff per step. After the last try, the error reaches your code to handle.
step.sleep('3 days') or step.sleepUntil(date), for reminders, trials and follow-ups.
step.waitForEvent() pauses until a webhook, payment or human approval arrives, with a timeout.
Inputs, results, errors and attempts for every instance in the dashboard and lyrcloud workflows status.
Launch: 10 workflows, 20,000 steps a month. Scale: 100 and 2M. Enterprise: 1,000 and 20M. Past that, $2 per 100,000 steps from Lyrcloud credit.
Register or transfer a domain with free WHOIS privacy and Lyrcloud DNS, paid by card or with Lyrpay.
Learn moreResponse caching, static files and whole static sites for your edge functions, with cache headers you control and purges from the CLI.
Learn moreRate limits, IP rules, a firewall for common attacks, bot checks and secure headers for your edge functions, set in lyrcloud.json and enforced before your code runs.
Learn moreCreate a free account in under a minute. No credit card required.