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

推荐订阅源

月光博客
月光博客
Scott Helme
Scott Helme
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
美团技术团队
T
Tailwind CSS Blog
博客园 - 叶小钗
小众软件
小众软件
云风的 BLOG
云风的 BLOG
S
SegmentFault 最新的问题
爱范儿
爱范儿
博客园 - Franky
量子位
I
InfoQ
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 【当耐特】
博客园_首页
Recorded Future
Recorded Future
The Register - Security
The Register - Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Recent Announcements
Recent Announcements
Martin Fowler
Martin Fowler
C
CERT Recently Published Vulnerability Notes
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
A
About on SuperTechFans
阮一峰的网络日志
阮一峰的网络日志
Cisco Talos Blog
Cisco Talos Blog
腾讯CDC
WordPress大学
WordPress大学
NISL@THU
NISL@THU
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyberwarzone
Cyberwarzone
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
The Hacker News
The Hacker News
N
News and Events Feed by Topic
Y
Y Combinator Blog
T
Troy Hunt's Blog
A
Arctic Wolf
V
V2EX
S
Secure Thoughts

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 node-js-module-in-workflow serialization-failed start-invalid-workflow-function step-not-registered timeout-in-workflow webhook-invalid-respond-with-value webhook-response-not-sent workflow-not-registered Errors & Retrying Hooks & Webhooks Idempotency Foundations Serialization Starting Workflows Streaming Versioning Workflows and Steps How the Directives Work Encryption Event Sourcing Framework Integrations Understanding Directives Migration Guides Migrating from AWS Step Functions Migrating from Inngest Migrating from Temporal Observability Testing Server-Based Testing createHook createWebhook defineHook FatalError fetch getStepMetadata getWorkflowMetadata getWritable workflow RetryableError sleep @workflow/vitest DurableAgent @workflow/ai WorkflowChatTransport getHookByToken getRun getWorld workflow/api resumeHook resumeWebhook Chat Session Modeling runtime-decryption-failed Upgrading Workflows abort-signal-timeout-in-workflow Cancellation How Cancellation Works Internal Serializable AbortController and AbortSignal Eager Processing of Steps & Incremental Event Replay TanStack Start Agent Cancellation Sequential & Parallel Execution Workflow Composition Local World | Workflow SDK Vercel World | Workflow SDK Migrating from trigger.dev Secure Credential Handling Local World | Workflow SDK Postgres World | Workflow SDK Vercel World | Workflow SDK
Postgres World | Workflow SDK
2026-04-16 · via Workflow SDK Documentation

The Postgres World is a production-ready backend for self-hosted deployments. It uses PostgreSQL for durable storage and graphile-worker for reliable job processing.

Use the Postgres World when you need to deploy workflows on your own infrastructure outside of Vercel - such as a Docker container, Kubernetes cluster, or any cloud that supports long-running servers.

Install the Postgres World package in your workflow project:

Configure the required environment variables to use the world and point it to your PostgreSQL database:

WORKFLOW_TARGET_WORLD="@workflow/world-postgres"
WORKFLOW_POSTGRES_URL="postgres://user:password@host:5432/database"

Run the migration script to create the necessary tables in your database. Ensure WORKFLOW_POSTGRES_URL is set when running this command:

npx workflow-postgres-setup

The migration is idempotent and can safely be run as a post-deployment lifecycle script.

To subscribe to the graphile-worker queue, your workflow app needs to start the world on server start. Here are examples for a few frameworks:

The Postgres World requires a long-lived worker process that polls the database for jobs. This does not work on serverless environments. For Vercel deployments, use the Vercel World instead.

Use the workflow CLI to inspect workflows stored in PostgreSQL:

# Set your database URL
export WORKFLOW_POSTGRES_URL="postgres://user:password@host:5432/database"

# List workflow runs
npx workflow inspect runs --backend @workflow/world-postgres

# Launch the web UI
npx workflow web --backend @workflow/world-postgres

If WORKFLOW_POSTGRES_URL is not set, the CLI defaults to postgres://world:world@localhost:5432/world.

Learn more in the Observability documentation.

E2E Tests

Passing100% passing

Spec compliance is tested against Next.js (Turbopack) built in production mode and started with `next start`. View CI run →

View comprehensive E2E test results against all frameworks/configurations

Last updated: 6/14/2026, 11:48:35 AM · Commit: 0178fa5

All configuration options can be set via environment variables or programmatically via createWorld().

WORKFLOW_POSTGRES_URL (required)

PostgreSQL connection string. Falls back to DATABASE_URL if not set.

Default: postgres://world:world@localhost:5432/world

WORKFLOW_POSTGRES_JOB_PREFIX

Prefix for graphile-worker queue job names. Useful when sharing a database between multiple applications.

WORKFLOW_POSTGRES_WORKER_CONCURRENCY

Number of concurrent workers polling for jobs. Default: 50.

This value also bounds how many parent→child workflow polls can be in flight simultaneously. Every await childRun.returnValue inside a workflow holds a worker slot until the child run terminates — if you expect recursive or highly-fanned-out parent/child workflows, raise this ceiling above the peak number of concurrent polls. With the default of 50, the included fibonacciWorkflow e2e test (fib(6), ~24 concurrent polls at peak) passes; deeper recursion or larger fanouts need a correspondingly larger setting.

WORKFLOW_POSTGRES_MAX_POOL_SIZE

Maximum size of the internal pg.Pool used when createWorld() constructs the pool. Default: 10

For higher worker concurrency, Graphile Worker recommends setting maxPoolSize to 10 or queueConcurrency + 2, whichever is larger.

Programmatic configuration

import { createWorld } from "@workflow/world-postgres";

const world = createWorld({
  connectionString: "postgres://user:password@host:5432/database",
  jobPrefix: "myapp_",
  queueConcurrency: 50,
  maxPoolSize: 52, // overrides WORKFLOW_POSTGRES_MAX_POOL_SIZE
});

The Postgres World uses PostgreSQL as a durable backend:

  • Storage - Workflow runs, events, steps, and hooks are stored in PostgreSQL tables
  • Job Queue - graphile-worker handles reliable job processing with retries
  • Streaming - PostgreSQL NOTIFY/LISTEN enables real-time event distribution

This architecture ensures workflows survive application restarts with all state reliably persisted. For implementation details, see the source code.

Deploy your application to any cloud that supports long-running servers:

  • Docker containers
  • Kubernetes clusters
  • Virtual machines
  • Platform-as-a-Service providers (Railway, Render, Fly.io, etc.)

Ensure your deployment has:

  1. Network access to your PostgreSQL database
  2. Environment variables configured correctly
  3. The start() function called on server initialization

The Postgres World is not compatible with Vercel deployments. On Vercel, workflows automatically use the Vercel World with zero configuration.

  • Requires long-running process - Must call start() on server initialization; not compatible with serverless platforms
  • PostgreSQL infrastructure - Requires a PostgreSQL database (self-hosted or managed)
  • Not compatible with Vercel - Use the Vercel World for Vercel deployments

For local development, use the Local World which requires no external services.