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

推荐订阅源

G
Google Developers Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
雷峰网
雷峰网
博客园_首页
The Cloudflare Blog
Hugging Face - Blog
Hugging Face - Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
小众软件
小众软件
D
Docker
P
Proofpoint News Feed
B
Blog
Vercel News
Vercel News
B
Blog RSS Feed
U
Unit 42
月光博客
月光博客
The GitHub Blog
The GitHub Blog
Apple Machine Learning Research
Apple Machine Learning Research
Y
Y Combinator Blog
I
InfoQ
Recent Announcements
Recent Announcements

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)) 
}