Sleep step.sleep()

Use step.sleep() to pause your function's execution for a specified duration. This is useful for adding delays between steps, such as waiting before sending a follow-up email or polling an external service at intervals.

step.sleep(id, duration): Promise

  • Name
    id
    Type
    string
    Required
    required
    Description

    The ID of the step. This will be what appears in your function's logs and is used to memoize step state across function versions.

  • Name
    duration
    Type
    number | string | Temporal.Duration
    Required
    required
    Description

    The duration of time to sleep:

    • number of milliseconds
    • string compatible with the ms package, e.g. "30m", "3 hours", or "2.5d"
    • Temporal.Duration
// Sleep for 30 minutes
const thirtyMins = Temporal.Duration.from({ minutes: 30 });
await step.sleep("wait-with-temporal", thirtyMins);

await step.sleep("wait-with-string", "30m");
await step.sleep("wait-with-string-alt", "30 minutes");
await step.sleep("wait-with-ms", 30 * 60 * 1000);

step.sleep() must be called using await or some other Promise handler to ensure your function sleeps correctly.