Sleep until a time step.sleepUntil()

Use step.sleepUntil() to pause the execution of your function until a specific date time.

export default inngest.createFunction(
  { name: "Send scheduled reminder" },
  { event: "app/reminder.scheduled" },
  async ({ event, step }) => {
    const d = new Date(
    await step.sleepUntil(d);
    // Do something else

To sleep until a particular amount of time from now, use step.sleep() instead.

step.sleep(datetime): Promise

  • Name
    Date | string

    The datetime at which to continue execution of your function. This can be:

// Sleep until the new year
await step.sleepUntil("2024-01-01");

// Sleep until September ends
await step.sleepUntil("2023-09-30T11:59:59");

// Sleep until the end of the this week
const d = dayjs().endOf('week').toDate();
await step.sleepUntil(d)

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