Timers
A durable timer pauses a function for any length of time without holding a worker. The engine records the timer in the history, the run waits, and when the timer fires the function continues from the line after the await, even if FluidGrids was redeployed in between.
Sleep
await ctx.sleep('3d', { summary: 'Grace period before the reminder' });
Durations are milliseconds or a string: '30s', '5m', '2h', '3d', or ISO 8601 such as 'PT2H'. The summary labels the timer in the History tab.
While a run sleeps its status is Waiting, and it uses no compute.
Wait for a condition
ctx.condition resolves when a predicate over the function's own state becomes true after an event (usually a signal), or returns false when the optional timeout passes first:
let approved = false;
ctx.onSignal(approve, () => { approved = true; });
const inTime = await ctx.condition(() => approved, '2d');
if (!inTime) {
await ctx.run(n.slack.sendMessage, { args: { channelId: 'C0OPS', text: 'Approval timed out' } });
}
Race a timer
Timers are promises, so the usual patterns work:
const decision = await Promise.race([
ctx.signalReceived(approve),
ctx.sleep('2d').then(() => undefined),
]);
When a timer is no longer needed, for example because its cancellation scope was cancelled, the engine cancels it and records TIMER_CANCELLED.
Never use real timers
setTimeout, setInterval and Date.now throw a DeterminismViolation inside workflow code. Use ctx.sleep and ctx.now().