惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
腾讯CDC
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
小众软件
小众软件
美团技术团队
Martin Fowler
Martin Fowler
爱范儿
爱范儿
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
J
Java Code Geeks
B
Blog
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
博客园 - Franky

Workflow SDK Documentation

Patterns for Defining Tools Human-in-the-Loop Building Durable AI Agents Queueing User Messages Resumable Streams Sleep, Suspense, and Scheduling Streaming Updates from Tools API Reference Workflow Globals Changelog Resilient run start Cookbook Building a World Deploying Astro Express Fastify Hono Getting Started NestJS Next.js Nitro Nuxt Python SvelteKit Vite corrupted-event-log fetch-in-workflow hook-conflict Errors
sleep
2026-05-31 · via Workflow SDK Documentation

Suspend a workflow for a duration or until a date without consuming resources.

Suspends a workflow for a specified duration or until an end date without consuming any resources. Once the duration or end date passes, the workflow will resume execution.

This is useful when you want to resume a workflow after some duration or date.

sleep is a special type of step function and should be called directly inside workflow functions.

import { sleep } from "workflow"

async function testWorkflow() {
    "use workflow"
    await sleep("10s") 
}

Parameters

This function has multiple signatures.

Signature 1

NameTypeDescription
durationStringValueThe duration to sleep for, this is a string in the format of "1000ms", "1s", "1m", "1h", or "1d".

Signature 2

NameTypeDescription
dateDateThe date to sleep until, this must be a future date.

Signature 3

NameTypeDescription
durationMsnumberThe duration to sleep for in milliseconds.

Sleeping With a Duration

You can specify a duration for sleep to suspend the workflow for a fixed amount of time.

import { sleep } from "workflow"

async function testWorkflow() {
    "use workflow"
    await sleep("1d") 
}

Sleeping Until an End Date

You can specify a future Date object for sleep to suspend the workflow until a specific date.

import { sleep } from "workflow"

async function testWorkflow() {
    "use workflow"
    await sleep(new Date(Date.now() + 10_000)) 
}