workflow 5.0.0-beta.34 → 5.0.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/internal/errors.d.ts +1 -1
- package/dist/internal/errors.d.ts.map +1 -1
- package/dist/internal/errors.js +2 -2
- package/dist/nest-builder.d.ts +2 -0
- package/dist/nest-builder.d.ts.map +1 -0
- package/dist/nest-builder.js +2 -0
- package/dist/nest-vercel-builder.d.ts +2 -0
- package/dist/nest-vercel-builder.d.ts.map +1 -0
- package/dist/nest-vercel-builder.js +2 -0
- package/docs/api-reference/workflow/create-hook.mdx +43 -2
- package/docs/api-reference/workflow/define-hook.mdx +26 -24
- package/docs/api-reference/workflow/fatal-error.mdx +29 -7
- package/docs/api-reference/workflow/fetch.mdx +3 -4
- package/docs/api-reference/workflow/sleep.mdx +1 -1
- package/docs/api-reference/workflow-api/get-hook-by-token.mdx +2 -0
- package/docs/api-reference/workflow-api/resume-hook.mdx +2 -0
- package/docs/api-reference/workflow-api/resume-webhook.mdx +6 -4
- package/docs/api-reference/workflow-api/start.mdx +1 -1
- package/docs/api-reference/workflow-errors/index.mdx +3 -0
- package/docs/api-reference/workflow-errors/meta.json +1 -0
- package/docs/api-reference/workflow-errors/precondition-failed-error.mdx +62 -0
- package/docs/api-reference/workflow-nest/nest-local-builder.mdx +1 -1
- package/docs/comparisons/index.mdx +66 -0
- package/docs/comparisons/meta.json +11 -0
- package/docs/comparisons/workflow-sdk-vs-aws-agentcore.mdx +55 -0
- package/docs/comparisons/workflow-sdk-vs-aws-step-functions.mdx +111 -0
- package/docs/comparisons/workflow-sdk-vs-cloudflare-workflows.mdx +71 -0
- package/docs/comparisons/workflow-sdk-vs-inngest.mdx +102 -0
- package/docs/comparisons/workflow-sdk-vs-temporal.mdx +123 -0
- package/docs/comparisons/workflow-sdk-vs-trigger-dev.mdx +103 -0
- package/docs/configuration/runtime-tuning.mdx +26 -0
- package/docs/configuration/worlds.mdx +6 -7
- package/docs/cookbook/common-patterns/idempotency.mdx +1 -1
- package/docs/{deploying/index.mdx → deploying.mdx} +6 -8
- package/docs/foundations/hooks.mdx +1 -1
- package/docs/foundations/idempotency.mdx +16 -9
- package/docs/getting-started/astro.mdx +1 -1
- package/docs/getting-started/express.mdx +1 -1
- package/docs/getting-started/fastify.mdx +1 -1
- package/docs/getting-started/hono.mdx +1 -1
- package/docs/getting-started/index.mdx +10 -3
- package/docs/getting-started/meta.json +3 -1
- package/docs/getting-started/nestjs.mdx +63 -2
- package/docs/getting-started/next.mdx +2 -2
- package/docs/getting-started/nitro.mdx +1 -1
- package/docs/getting-started/nuxt.mdx +1 -1
- package/docs/getting-started/python.mdx +19 -17
- package/docs/getting-started/react-router/index.mdx +33 -0
- package/docs/getting-started/react-router/meta.json +5 -0
- package/docs/getting-started/react-router/v7.mdx +237 -0
- package/docs/getting-started/react-router/v8.mdx +232 -0
- package/docs/getting-started/sveltekit.mdx +1 -1
- package/docs/getting-started/vite.mdx +1 -1
- package/docs/how-it-works/encryption.mdx +3 -3
- package/docs/how-it-works/event-sourcing.mdx +6 -6
- package/docs/how-it-works/framework-integrations.mdx +3 -3
- package/docs/meta.json +1 -1
- package/docs/observability/attributes.mdx +9 -0
- package/package.json +13 -11
- package/docs/deploying/building-a-world.mdx +0 -251
- package/docs/deploying/meta.json +0 -4
- package/docs/deploying/world/local-world.mdx +0 -101
- package/docs/deploying/world/meta.json +0 -4
- package/docs/deploying/world/postgres-world.mdx +0 -288
- package/docs/deploying/world/vercel-world.mdx +0 -275
- package/docs/migration-guides/index.mdx +0 -34
- package/docs/migration-guides/meta.json +0 -9
- package/docs/migration-guides/migrating-from-aws-step-functions.mdx +0 -362
- package/docs/migration-guides/migrating-from-inngest.mdx +0 -308
- package/docs/migration-guides/migrating-from-temporal.mdx +0 -317
- package/docs/migration-guides/migrating-from-trigger-dev.mdx +0 -332
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Migrating from AWS Step Functions
|
|
3
|
-
description: Move an AWS Step Functions state machine to the Workflow SDK by replacing JSON state definitions, Task states, Choice/Wait/Parallel states, Retry/Catch blocks, and .waitForTaskToken callbacks with Workflows, Steps, Hooks, and idiomatic TypeScript control flow.
|
|
4
|
-
type: guide
|
|
5
|
-
summary: Translate an AWS Step Functions state machine into the Workflow SDK with side-by-side code examples.
|
|
6
|
-
prerequisites:
|
|
7
|
-
- /docs/getting-started/next
|
|
8
|
-
- /docs/foundations/workflows-and-steps
|
|
9
|
-
related:
|
|
10
|
-
- /docs/foundations/starting-workflows
|
|
11
|
-
- /docs/foundations/errors-and-retries
|
|
12
|
-
- /docs/foundations/hooks
|
|
13
|
-
- /docs/foundations/streaming
|
|
14
|
-
- /docs/deploying/world/vercel-world
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
<CopyPrompt
|
|
18
|
-
text="Replace this AWS Step Functions state machine with Workflow SDK. Run `npm i workflow`. Translate the ASL state machine into an exported async TypeScript function with `"use workflow"`. Move each Lambda/Task side effect into a helper function with `"use step"`. Replace Wait states with `sleep()` from `workflow`. Replace callback tokens with `defineHook()` plus `resumeHook()` from `workflow/api`, or `createWebhook()` for HTTP callbacks. Replace Parallel and Map states with `Promise.all`, bounded batching, or child workflow runs started with `start()`. Replace Retry/Catch rules with normal errors, `RetryableError`, and `FatalError`. Add an API route or server function that starts the workflow with `start(workflowFn, args)` and verify it against the previous state machine behavior."
|
|
19
|
-
/>
|
|
20
|
-
|
|
21
|
-
Move an AWS Step Functions state machine to the Workflow SDK by replacing JSON state definitions with TypeScript functions. This guide shows the direct mapping between ASL states and Workflow SDK primitives.
|
|
22
|
-
|
|
23
|
-
<Callout type="info">
|
|
24
|
-
Install the Workflow SDK migration skill:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npx skills add https://github.com/vercel/workflow --skill migrating-to-workflow-sdk
|
|
28
|
-
```
|
|
29
|
-
</Callout>
|
|
30
|
-
|
|
31
|
-
## Why migrate to the Workflow SDK
|
|
32
|
-
|
|
33
|
-
- Orchestration code is TypeScript, not JSON ASL. Transitions are `await`, branches are `if`/`switch`, and parallelism is `Promise.all`.
|
|
34
|
-
- Streaming is built in. Write durable progress from steps with `getWritable()` and named streams. No DynamoDB or SNS glue to surface status to clients.
|
|
35
|
-
- Infrastructure lives in one deployment. No separate state machine, per-task Lambda, IAM role wiring, or callback SQS queues.
|
|
36
|
-
- Error handling is TypeScript-native: step-level retries, `RetryableError`, and `FatalError` replace per-state Retry/Catch blocks.
|
|
37
|
-
- The `npx workflow` CLI and `npx workflow web` observability UI ship out of the box.
|
|
38
|
-
- AI/agent helpers — `@workflow/ai` for AI-SDK integration and the Claude migration skill — are available as separate installs.
|
|
39
|
-
|
|
40
|
-
## Before you migrate
|
|
41
|
-
|
|
42
|
-
This guide assumes **Standard** workflows. Express workflows have different semantics (at-least-once, 5-minute max duration, no execution history) and may need a different target — consider keeping them on Step Functions, moving them to a queue consumer, or ensuring your steps are idempotent before replaying the pattern here.
|
|
43
|
-
|
|
44
|
-
## What changes when you leave Step Functions?
|
|
45
|
-
|
|
46
|
-
AWS Step Functions defines workflows as JSON state machines using Amazon States Language (ASL). Each state (Task, Choice, Wait, Parallel, Map) is a node in a declarative graph. Lambda functions handle tasks, Retry/Catch blocks configure per-state error handling, and `.waitForTaskToken` manages callbacks.
|
|
47
|
-
|
|
48
|
-
The Workflow SDK replaces that JSON DSL with TypeScript. `"use workflow"` functions orchestrate `"use step"` functions in the same file. Branching is `if`/`else`. Waiting is `sleep()`. Parallelism is `Promise.all()`. Retries move down to the step level.
|
|
49
|
-
|
|
50
|
-
The migration replaces declarative configuration with idiomatic TypeScript and collapses the orchestrator and compute split. Business logic stays the same.
|
|
51
|
-
|
|
52
|
-
## Concept mapping
|
|
53
|
-
|
|
54
|
-
| AWS Step Functions | Workflow SDK | Migration note |
|
|
55
|
-
| --- | --- | --- |
|
|
56
|
-
| State machine (ASL JSON) | `"use workflow"` function | The workflow function is the state machine. |
|
|
57
|
-
| Task state / Lambda | `"use step"` function | Side effects go in steps. No separate Lambda. |
|
|
58
|
-
| Choice state | `if` / `else` / `switch` | Native TypeScript control flow. |
|
|
59
|
-
| Wait state | `sleep()` | Import `sleep` from `workflow`. |
|
|
60
|
-
| Parallel state | `Promise.all()` | Standard concurrency primitives. |
|
|
61
|
-
| Map state | Inline sequential → `for` loop; bounded parallel (`MaxConcurrency: N`) → batched `Promise.all` or a concurrency limiter like `p-limit`; Distributed Map / large fan-out → `start()` per item, then step-wrapped `getRun()` to collect. | Match the concurrency mode of the original Map. |
|
|
62
|
-
| Retry / Catch | Step retries, `RetryableError`, `FatalError` | Retry logic moves to step boundaries. |
|
|
63
|
-
| `Catch` to a compensation state | `try`/`catch` in the workflow function, calling compensation steps in reverse order (push/pop a rollback stack) | See [`/docs/foundations/errors-and-retries`](/docs/foundations/errors-and-retries) for the SAGA pattern. |
|
|
64
|
-
| `.waitForTaskToken` | `createHook()` or `createWebhook()` | Hooks for typed signals; webhooks for HTTP. |
|
|
65
|
-
| Child state machine (`StartExecution`) | `start()` plus a `"use step"` wrapper around `getRun()` | Return the `Run` object, await its result from another step. |
|
|
66
|
-
| Execution event history | Workflow event log | Same durable replay model. |
|
|
67
|
-
| Progress via DynamoDB / SNS for client polling | `getWritable()` + named streams | Stream durable updates; clients read from the stream. |
|
|
68
|
-
|
|
69
|
-
<Callout type="info">
|
|
70
|
-
`.waitForTaskToken` becomes `createHook()` or `createWebhook()`. Choice states become `if`/`else`. Map states become `Promise.all()`. Retry policies move from per-state configuration to step-level defaults.
|
|
71
|
-
</Callout>
|
|
72
|
-
|
|
73
|
-
## Translate your first workflow
|
|
74
|
-
|
|
75
|
-
Start with a single Task state. In ASL, even "call one Lambda" requires a state machine shell:
|
|
76
|
-
|
|
77
|
-
```json title="stateMachine.asl.json (Step Functions)"
|
|
78
|
-
"LoadOrder": {
|
|
79
|
-
"Type": "Task",
|
|
80
|
-
"Resource": "arn:aws:states:::lambda:invoke",
|
|
81
|
-
"Parameters": { "FunctionName": "loadOrder", "Payload.$": "$" },
|
|
82
|
-
"End": true
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
<Callout type="info">
|
|
87
|
-
Examples use JSONPath mode. If your state machine sets `QueryLanguage: 'JSONata'`, the shape of `Arguments`/`Output` fields differs but the TypeScript translation is identical.
|
|
88
|
-
</Callout>
|
|
89
|
-
|
|
90
|
-
```typescript title="workflow/workflows/order.ts (Workflow SDK)"
|
|
91
|
-
export async function processOrder(orderId: string) {
|
|
92
|
-
'use workflow'; // [!code highlight]
|
|
93
|
-
return await loadOrder(orderId);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async function loadOrder(orderId: string) {
|
|
97
|
-
'use step'; // [!code highlight]
|
|
98
|
-
const res = await fetch(`https://example.com/api/orders/${orderId}`);
|
|
99
|
-
return res.json() as Promise<{ id: string }>;
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
What changed: the ASL state machine and its Lambda collapse into two directive-tagged functions in one file.
|
|
104
|
-
|
|
105
|
-
### Adding a second step
|
|
106
|
-
|
|
107
|
-
In ASL, a second Task means a new state and a `"Next"` transition. In the Workflow SDK, it's another `await`:
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
export async function processOrder(orderId: string) {
|
|
111
|
-
'use workflow';
|
|
112
|
-
const order = await loadOrder(orderId);
|
|
113
|
-
await reserveInventory(order.id); // [!code highlight]
|
|
114
|
-
return { orderId: order.id, status: 'reserved' };
|
|
115
|
-
}
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
`await` replaces `"Next"`. Each new step is a new function with `"use step"`; no additional deployment. The second version also reshapes the return value; the workflow return type can be anything serializable.
|
|
119
|
-
|
|
120
|
-
### Starting from an API route
|
|
121
|
-
|
|
122
|
-
Step Functions starts a run via `StartExecution` (AWS SDK or API Gateway integration). The Workflow SDK starts a run with `start()` from a route handler:
|
|
123
|
-
|
|
124
|
-
```typescript title="app/api/orders/route.ts"
|
|
125
|
-
import { start } from 'workflow/api';
|
|
126
|
-
import { processOrder } from '@/workflows/order';
|
|
127
|
-
|
|
128
|
-
export async function POST(request: Request) {
|
|
129
|
-
const { orderId } = (await request.json()) as { orderId: string };
|
|
130
|
-
const run = await start(processOrder, [orderId]); // [!code highlight]
|
|
131
|
-
return Response.json({ runId: run.runId });
|
|
132
|
-
}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Waiting for a fixed duration
|
|
136
|
-
|
|
137
|
-
A `Wait` state becomes `sleep()`:
|
|
138
|
-
|
|
139
|
-
```json title="stateMachine.asl.json (Step Functions)"
|
|
140
|
-
{ "Type": "Wait", "Seconds": 60, "Next": "Next" }
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
{/* @skip-typecheck: one-line snippet fragment */}
|
|
144
|
-
|
|
145
|
-
```typescript title="workflow/workflows/order.ts (Workflow SDK)"
|
|
146
|
-
await sleep('1m');
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
## Wait for an external signal
|
|
150
|
-
|
|
151
|
-
The minimal ASL for a callback is a Task with `.waitForTaskToken`:
|
|
152
|
-
|
|
153
|
-
```json title="approval.asl.json (Step Functions)"
|
|
154
|
-
"WaitForApproval": {
|
|
155
|
-
"Type": "Task",
|
|
156
|
-
"Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken",
|
|
157
|
-
"Parameters": {
|
|
158
|
-
"QueueUrl": "https://sqs.us-east-1.amazonaws.com/123456789012/approvals",
|
|
159
|
-
"MessageBody": {
|
|
160
|
-
"refundId.$": "$.refundId",
|
|
161
|
-
"TaskToken.$": "$$.Task.Token"
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
"End": true
|
|
165
|
-
}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
```typescript title="workflow/workflows/refund.ts (Workflow SDK)"
|
|
169
|
-
import { createHook } from 'workflow';
|
|
170
|
-
|
|
171
|
-
export async function refundWorkflow(refundId: string) {
|
|
172
|
-
'use workflow';
|
|
173
|
-
using approval = createHook<{ approved: boolean }>({ // [!code highlight]
|
|
174
|
-
token: `refund:${refundId}:approval`,
|
|
175
|
-
});
|
|
176
|
-
return await approval;
|
|
177
|
-
}
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
What changed: no SQS queue, no task token, no callback Lambda. The hook suspends the workflow durably until it is resumed.
|
|
181
|
-
|
|
182
|
-
### Resuming the hook
|
|
183
|
-
|
|
184
|
-
Step Functions resumes by calling `SendTaskSuccess` with the task token. The Workflow SDK resumes by calling `resumeHook` with the hook's token:
|
|
185
|
-
|
|
186
|
-
```typescript title="app/api/refunds/[refundId]/approve/route.ts"
|
|
187
|
-
import { resumeHook } from 'workflow/api';
|
|
188
|
-
|
|
189
|
-
export async function POST(req: Request, { params }: { params: Promise<{ refundId: string }> }) {
|
|
190
|
-
const { refundId } = await params;
|
|
191
|
-
const { approved } = (await req.json()) as { approved: boolean };
|
|
192
|
-
await resumeHook(`refund:${refundId}:approval`, { approved }); // [!code highlight]
|
|
193
|
-
return Response.json({ ok: true });
|
|
194
|
-
}
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
### Branching on the result
|
|
198
|
-
|
|
199
|
-
In ASL, branching after the wait requires a Choice state. In TypeScript, it's just `if`/`else`:
|
|
200
|
-
|
|
201
|
-
```json title="approval.asl.json (Step Functions)"
|
|
202
|
-
"CheckApproval": {
|
|
203
|
-
"Type": "Choice",
|
|
204
|
-
"Choices": [
|
|
205
|
-
{ "Variable": "$.approved", "BooleanEquals": true, "Next": "Approved" }
|
|
206
|
-
],
|
|
207
|
-
"Default": "Rejected"
|
|
208
|
-
}
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
{/* @skip-typecheck: continuation snippet */}
|
|
212
|
-
```typescript title="workflow/workflows/refund.ts (Workflow SDK)"
|
|
213
|
-
const { approved } = await approval;
|
|
214
|
-
if (approved) return { refundId, status: 'approved' }; // [!code highlight]
|
|
215
|
-
return { refundId, status: 'rejected' };
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
## Spawn a child workflow
|
|
219
|
-
|
|
220
|
-
In ASL, a parent machine calls `StartExecution` (usually via `.sync` or `.waitForTaskToken`) to launch a child. In v5, call `start()` directly from the workflow to launch a child. Wrap `getRun()` and `returnValue` access in a `"use step"` function when you need to await the child result.
|
|
221
|
-
|
|
222
|
-
### Parent starts a child
|
|
223
|
-
|
|
224
|
-
```typescript title="workflow/workflows/parent.ts"
|
|
225
|
-
import { start } from 'workflow/api';
|
|
226
|
-
|
|
227
|
-
export async function parentWorkflow(item: string) {
|
|
228
|
-
'use workflow';
|
|
229
|
-
const run = await start(childWorkflow, [item]); // [!code highlight]
|
|
230
|
-
return { childRunId: run.runId };
|
|
231
|
-
}
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
### Awaiting the child's result
|
|
235
|
-
|
|
236
|
-
Add a second step that wraps `getRun()` and awaits `returnValue`:
|
|
237
|
-
|
|
238
|
-
```typescript
|
|
239
|
-
import { getRun } from 'workflow/api';
|
|
240
|
-
|
|
241
|
-
async function collectResult(runId: string) {
|
|
242
|
-
'use step'; // [!code highlight]
|
|
243
|
-
const run = getRun(runId);
|
|
244
|
-
return (await run.returnValue) as { item: string; result: string };
|
|
245
|
-
}
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
Then in the workflow: `const result = await collectResult(run.runId);`. The child workflow itself (`childWorkflow`) is defined elsewhere with `"use workflow"`.
|
|
249
|
-
|
|
250
|
-
## What you stop operating
|
|
251
|
-
|
|
252
|
-
Moving off Step Functions removes these surfaces from the application:
|
|
253
|
-
|
|
254
|
-
- ASL state machine JSON and its reference syntax.
|
|
255
|
-
- Per-task Lambda functions, their IAM roles, and CloudFormation/CDK wiring.
|
|
256
|
-
- Task-token delivery infrastructure (SQS queues, callback Lambdas).
|
|
257
|
-
- Separate progress channels (DynamoDB, SNS) for client-visible updates.
|
|
258
|
-
- Remove CloudWatch and X-Ray wiring that was specific to orchestrator state transitions. Keep (or re-wire) any application-level CloudWatch alarms, log retention policies, or X-Ray propagation that the rest of your AWS footprint still depends on. Workflow SDK exports OTEL traces, so existing OTEL-compatible backends can continue to ingest them.
|
|
259
|
-
|
|
260
|
-
Workflow and step functions live in the same deployment as the application. State transitions are ordinary control flow (`await`, `if`, `Promise.all`, `for`). Progress streaming, retries, and observability are built in.
|
|
261
|
-
|
|
262
|
-
### What you take on
|
|
263
|
-
|
|
264
|
-
Steps that previously invoked AWS services via optimized integrations (EventBridge, DynamoDB, Bedrock, ECS.RunTask.sync, etc.) become ordinary SDK calls inside `'use step'` functions. Credentials and retries move into the step, and `.sync`-style waits for long-running jobs become explicit polling loops or hook-based callbacks.
|
|
265
|
-
|
|
266
|
-
## Step-by-step first migration
|
|
267
|
-
|
|
268
|
-
Pick one state machine and migrate it end-to-end before touching the rest. The steps below describe the smallest viable path.
|
|
269
|
-
|
|
270
|
-
### Step 1: Install the Workflow SDK
|
|
271
|
-
|
|
272
|
-
Add the `workflow` runtime package.
|
|
273
|
-
|
|
274
|
-
```bash
|
|
275
|
-
pnpm add workflow
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
### Step 2: Rewrite the state machine as a `"use workflow"` function
|
|
279
|
-
|
|
280
|
-
Transitions become `await` calls. Control flow (`Choice`, `Wait`, `Parallel`, `Map`) becomes `if`/`switch`, `sleep`, `Promise.all`, and loops.
|
|
281
|
-
|
|
282
|
-
```ts title="workflows/order.ts"
|
|
283
|
-
export async function processOrder(orderId: string) {
|
|
284
|
-
"use workflow"; // [!code highlight]
|
|
285
|
-
const order = await loadOrder(orderId);
|
|
286
|
-
if (order.total > 1000) await reviewManually(order);
|
|
287
|
-
await chargePayment(order);
|
|
288
|
-
}
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
### Step 3: Move each Lambda into a step function
|
|
292
|
-
|
|
293
|
-
Inline the Lambda body into a function with `"use step"` on the first line. Step functions keep full Node.js access, so existing SDK calls work unchanged.
|
|
294
|
-
|
|
295
|
-
```ts
|
|
296
|
-
async function loadOrder(id: string) {
|
|
297
|
-
"use step"; // [!code highlight]
|
|
298
|
-
return fetch(`/api/orders/${id}`).then((r) => r.json());
|
|
299
|
-
}
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
### Step 4: Replace `.waitForTaskToken` with a hook
|
|
303
|
-
|
|
304
|
-
Swap the task-token callback Lambda for `createHook()`. Callers `resumeHook(token, payload)` instead of `SendTaskSuccess`.
|
|
305
|
-
|
|
306
|
-
Move Retry/Catch off per-state configuration and onto step boundaries. Set `maxRetries` as a function property; throw `RetryableError` or `FatalError` to control retry behavior:
|
|
307
|
-
|
|
308
|
-
```typescript
|
|
309
|
-
async function chargePayment(orderId: string) {
|
|
310
|
-
"use step";
|
|
311
|
-
// ...
|
|
312
|
-
}
|
|
313
|
-
chargePayment.maxRetries = 5;
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
See [`/docs/foundations/errors-and-retries`](/docs/foundations/errors-and-retries) for the full retry and SAGA compensation patterns.
|
|
317
|
-
|
|
318
|
-
### Step 5: Start runs from an API route
|
|
319
|
-
|
|
320
|
-
Delete the `StartExecution` call and IAM wiring. Launch runs directly from a route handler:
|
|
321
|
-
|
|
322
|
-
```ts title="app/api/orders/route.ts"
|
|
323
|
-
import { start } from "workflow/api";
|
|
324
|
-
import { processOrder } from "@/workflows/order";
|
|
325
|
-
|
|
326
|
-
export async function POST(req: Request) {
|
|
327
|
-
const { orderId } = await req.json();
|
|
328
|
-
const run = await start(processOrder, [orderId]);
|
|
329
|
-
return Response.json({ runId: run.runId });
|
|
330
|
-
}
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
### Step 6: Retire the Step Functions infrastructure
|
|
334
|
-
|
|
335
|
-
Delete the ASL JSON, per-task Lambda deployments, IAM roles, and callback queues. Remove CloudWatch and X-Ray wiring that was specific to orchestrator state transitions — keep alarms, log retention, and traces for resources you still depend on. Verify the run in `npx workflow web` before shipping.
|
|
336
|
-
|
|
337
|
-
## Features without a 1:1 equivalent
|
|
338
|
-
|
|
339
|
-
- **Express workflows.** At-least-once semantics and 5-minute duration make them a poor fit for the SDK's durable replay model. Consider keeping them on Step Functions or migrating to a queue consumer.
|
|
340
|
-
- **Distributed Map state.** Up to 10,000 concurrent child executions with S3 item sources has no 1:1 analog; fan out with `start()` per item, then `Promise.all` with `p-limit` to bound concurrency.
|
|
341
|
-
- **Optimized AWS service integrations (`arn:aws:states:::dynamodb:*`, `eventbridge:*`, `bedrock:*`, `ecs:runTask.sync`, etc.).** These become regular SDK calls inside `'use step'` functions — credentials, retries, and polling move into the step.
|
|
342
|
-
- **Per-state IAM roles.** ASL lets each state run under its own IAM role. In the SDK, all steps share the deployment's credentials; scope secrets and roles at deployment time.
|
|
343
|
-
- **CloudWatch alarms / X-Ray cross-service traces / CloudWatch Logs retention.** The SDK event log + observability UI replaces orchestrator state transitions, not AWS-wide observability. Keep alarms and traces for other resources.
|
|
344
|
-
- **`JSONata` `QueryLanguage` mode.** Valid at the source; the TS translation is identical regardless of mode.
|
|
345
|
-
|
|
346
|
-
## Quick-start checklist
|
|
347
|
-
|
|
348
|
-
- Replace the ASL state machine with a single `"use workflow"` function. Transitions become `await` calls.
|
|
349
|
-
- Convert each Task / Lambda into a `"use step"` function in the same file.
|
|
350
|
-
- Replace Choice states with `if`/`else`/`switch`.
|
|
351
|
-
- Replace Wait states with `sleep()` from `workflow`.
|
|
352
|
-
- Replace Parallel states with `Promise.all()`.
|
|
353
|
-
- Replace Map states based on their concurrency mode: inline sequential → `for` loop; bounded parallel (`MaxConcurrency: N`) → batched `Promise.all` or a concurrency limiter like `p-limit`; Distributed Map / large fan-out → `start()` per item, then step-wrapped `getRun()` to collect.
|
|
354
|
-
- Replace `StartExecution` child machines with direct `start()` calls and a `"use step"` wrapper around `getRun()` when collecting results.
|
|
355
|
-
- Replace `.waitForTaskToken` with `createHook()` (internal callers) or `createWebhook()` (HTTP callers).
|
|
356
|
-
- Move Retry/Catch to step boundaries using `maxRetries`, `RetryableError`, and `FatalError`.
|
|
357
|
-
- Use `getStepMetadata().stepId` as the idempotency key for external side effects.
|
|
358
|
-
- Stream progress from steps with `getWritable()` instead of polling DynamoDB or SNS.
|
|
359
|
-
- Deploy and verify runs end-to-end with built-in observability.
|
|
360
|
-
|
|
361
|
-
---
|
|
362
|
-
*Verified against `workflow@5.0.0-beta.1` and the AWS Step Functions Amazon States Language spec on 2026-04-16.*
|
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Migrating from Inngest
|
|
3
|
-
description: Move an Inngest TypeScript SDK v3 or v4 app to the Workflow SDK by replacing createFunction, step.run(), step.sleep(), step.waitForEvent(), and step.invoke() with Workflows, Steps, Hooks, and start()/getRun().
|
|
4
|
-
type: guide
|
|
5
|
-
summary: Translate an Inngest app into the Workflow SDK with side-by-side code examples.
|
|
6
|
-
prerequisites:
|
|
7
|
-
- /docs/getting-started/next
|
|
8
|
-
- /docs/foundations/workflows-and-steps
|
|
9
|
-
related:
|
|
10
|
-
- /docs/foundations/starting-workflows
|
|
11
|
-
- /docs/foundations/errors-and-retries
|
|
12
|
-
- /docs/foundations/hooks
|
|
13
|
-
- /docs/foundations/streaming
|
|
14
|
-
- /docs/deploying/world/vercel-world
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
<CopyPrompt
|
|
18
|
-
text="Migrate this Inngest code to Workflow SDK. Run `npm i workflow`. Replace each `inngest.createFunction` handler with an exported async function that contains `"use workflow"`. Replace each `step.run()` callback with a helper function that contains `"use step"`. Replace `step.sleep()` with `sleep()` from `workflow`. Replace event waits with `defineHook()` or `createWebhook()` from `workflow`, and resume them from server routes with `resumeHook()` or webhook requests. Start runs from API routes or server code with `start(workflowFn, args)` from `workflow/api`, and use `getRun(runId)` where callers need status, streams, cancellation, or results. Preserve retries by throwing normal errors for retryable failures and `FatalError` for permanent failures. Add a local test or route call that starts the migrated workflow and verifies the same observable behavior as the Inngest function."
|
|
19
|
-
/>
|
|
20
|
-
|
|
21
|
-
<Callout type="info">
|
|
22
|
-
Install the Workflow SDK migration skill:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npx skills add https://github.com/vercel/workflow --skill migrating-to-workflow-sdk
|
|
26
|
-
```
|
|
27
|
-
</Callout>
|
|
28
|
-
|
|
29
|
-
## Why migrate to the Workflow SDK
|
|
30
|
-
|
|
31
|
-
- Streaming is built in. Durable progress writes go to named streams via `getWritable()`. There is no separate realtime publish channel or WebSocket layer to operate.
|
|
32
|
-
- Infrastructure and orchestration live in a single deployment. Workflows run where the app runs. There is no separate Inngest Dev Server or event bus to operate.
|
|
33
|
-
- TypeScript-first DX. Steps are named async functions marked with `"use step"`. No inline closures tied to a framework-specific lifecycle.
|
|
34
|
-
- Agent-first tooling: the `npx workflow` CLI, `@workflow/ai` integration for durable AI agents, and a Claude skill for generating workflows.
|
|
35
|
-
|
|
36
|
-
Inngest code samples in this guide use the v4 two-argument `createFunction({ id, triggers }, handler)` shape. If the app is still on Inngest v3, treat the three-argument form `createFunction({ id }, { event: '...' }, handler)` as equivalent — the `triggers` option in v4 replaces the second argument in v3.
|
|
37
|
-
|
|
38
|
-
## What changes when you leave Inngest
|
|
39
|
-
|
|
40
|
-
Inngest defines functions with `inngest.createFunction()`, registers them through a `serve()` handler, and breaks work into steps with `step.run()`, `step.sleep()`, and `step.waitForEvent()`. The platform routes events, schedules steps, and applies retries.
|
|
41
|
-
|
|
42
|
-
The Workflow SDK replaces that with `"use workflow"` functions that orchestrate `"use step"` functions in plain TypeScript. There is no function registry, event dispatch layer, or SDK client. Durable replay, automatic retries, and step-level persistence are built into the runtime.
|
|
43
|
-
|
|
44
|
-
Migration collapses the SDK abstraction into plain async functions. Business logic stays the same.
|
|
45
|
-
|
|
46
|
-
<Callout type="info">
|
|
47
|
-
Inngest's event-bus model is loosely coupled — publishers don't know consumers. `start()` requires the caller to import the workflow function directly, giving stronger type safety but tighter coupling. For event-bus-like fan-out, wrap `start()` in a shared publisher module.
|
|
48
|
-
</Callout>
|
|
49
|
-
|
|
50
|
-
## Concept mapping
|
|
51
|
-
|
|
52
|
-
| Inngest | Workflow SDK | Migration note |
|
|
53
|
-
| --- | --- | --- |
|
|
54
|
-
| `inngest.createFunction()` | `"use workflow"` function started with `start()` | No wrapper needed. |
|
|
55
|
-
| `step.run()` | `"use step"` function | Standalone async function with Node.js access. |
|
|
56
|
-
| `step.sleep()` / `step.sleepUntil()` | `sleep()` | `sleep('5m')` for a duration; `sleep(date)` for sleep-until. |
|
|
57
|
-
| `step.waitForEvent()` | `createHook()` or `createWebhook()` | Hooks for typed signals, webhooks for HTTP. |
|
|
58
|
-
| `step.invoke()` | `start()` plus a `"use step"` wrapper around `getRun()` | Spawn a child run, pass `runId` forward, and collect from a step when needed. |
|
|
59
|
-
| `inngest.send()` / event triggers | `start()` from your app boundary | Start workflows directly. |
|
|
60
|
-
| Retry configuration (`retries`) | `RetryableError`, `FatalError`, `maxRetries` | Retry logic lives at the step level. |
|
|
61
|
-
| `step.sendEvent()` | `start()` from the workflow or app boundary | Fan out explicitly, not through an event bus. |
|
|
62
|
-
| Realtime / `step.realtime.publish()` | `getWritable()` / `getWritable({ namespace })` | Named streams are the canonical way for clients to read workflow status. No database or `getRun()` polling required. |
|
|
63
|
-
|
|
64
|
-
## Translate your first workflow
|
|
65
|
-
|
|
66
|
-
Start with the shell of a function. Inngest wraps it in `createFunction`; Workflow SDK marks it with a directive.
|
|
67
|
-
|
|
68
|
-
{/* @skip-typecheck: Inngest SDK types not available */}
|
|
69
|
-
```typescript title="inngest/functions/order.ts"
|
|
70
|
-
export const processOrder = inngest.createFunction(
|
|
71
|
-
{
|
|
72
|
-
id: 'process-order',
|
|
73
|
-
triggers: { event: 'order/created' },
|
|
74
|
-
},
|
|
75
|
-
async ({ event, step }) => {
|
|
76
|
-
return { orderId: event.data.orderId, status: 'completed' };
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
```typescript title="workflow/workflows/order.ts"
|
|
82
|
-
export async function processOrder(orderId: string) {
|
|
83
|
-
'use workflow'; // [!code highlight]
|
|
84
|
-
return { orderId, status: 'completed' };
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
**What changed:** the factory + event binding collapses into a plain exported function with a `"use workflow"` directive.
|
|
89
|
-
|
|
90
|
-
### Add a step
|
|
91
|
-
|
|
92
|
-
`step.run()` closures become named `"use step"` functions.
|
|
93
|
-
|
|
94
|
-
```typescript title="workflow/workflows/order.ts"
|
|
95
|
-
async function loadOrder(orderId: string) {
|
|
96
|
-
'use step'; // [!code highlight]
|
|
97
|
-
const res = await fetch(`https://example.com/api/orders/${orderId}`);
|
|
98
|
-
return res.json() as Promise<{ id: string }>;
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Call it from the workflow like any async function: `const order = await loadOrder(orderId)`. Additional side effects (`reserveInventory`, `chargePayment`) follow the same shape.
|
|
103
|
-
|
|
104
|
-
### Start the run
|
|
105
|
-
|
|
106
|
-
Inngest dispatches via `inngest.send({ name: 'order/created', data: { orderId } })`. Workflow SDK launches directly:
|
|
107
|
-
|
|
108
|
-
```typescript title="app/api/orders/route.ts"
|
|
109
|
-
import { start } from 'workflow/api';
|
|
110
|
-
import { processOrder } from '@/workflows/order';
|
|
111
|
-
|
|
112
|
-
const run = await start(processOrder, [orderId]); // [!code highlight]
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
No event bus, no registry. `start()` returns a handle immediately.
|
|
116
|
-
|
|
117
|
-
## Wait for an external signal
|
|
118
|
-
|
|
119
|
-
`step.waitForEvent()` becomes `createHook()` plus `await`.
|
|
120
|
-
|
|
121
|
-
```typescript title="workflow/workflows/refund.ts (Inngest)"
|
|
122
|
-
const approval = await step.waitForEvent('wait-for-approval', {
|
|
123
|
-
event: 'refund/approved',
|
|
124
|
-
match: 'data.refundId',
|
|
125
|
-
timeout: '7d',
|
|
126
|
-
});
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
{/* @skip-typecheck: snippet without imports */}
|
|
130
|
-
```typescript title="workflow/workflows/refund.ts (Workflow SDK)"
|
|
131
|
-
using approval = createHook<{ approved: boolean }>({ // [!code highlight]
|
|
132
|
-
token: `refund:${refundId}:approval`,
|
|
133
|
-
});
|
|
134
|
-
const payload = await approval;
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
**What changed:** event name + match expression collapse into a single `token` string. The caller supplies that token directly, with no event schema.
|
|
138
|
-
|
|
139
|
-
### Resume from an API route
|
|
140
|
-
|
|
141
|
-
Inngest resumes with `inngest.send({ name: 'refund/approved', data: { refundId, approved } })`. The SDK equivalent is `resumeHook`:
|
|
142
|
-
|
|
143
|
-
```typescript title="app/api/refunds/[refundId]/approve/route.ts"
|
|
144
|
-
import { resumeHook } from 'workflow/api';
|
|
145
|
-
|
|
146
|
-
export async function POST(request: Request, { params }: { params: Promise<{ refundId: string }> }) {
|
|
147
|
-
const { refundId } = await params;
|
|
148
|
-
const { approved } = (await request.json()) as { approved: boolean };
|
|
149
|
-
await resumeHook(`refund:${refundId}:approval`, { approved }); // [!code highlight]
|
|
150
|
-
return Response.json({ ok: true });
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### Add a timeout and branch on the payload
|
|
155
|
-
|
|
156
|
-
Inngest's `timeout: '7d'` option maps to a `Promise.race()` with `sleep()`:
|
|
157
|
-
|
|
158
|
-
{/* @skip-typecheck: continuation snippet */}
|
|
159
|
-
```typescript title="workflow/workflows/refund.ts"
|
|
160
|
-
const result = await Promise.race([
|
|
161
|
-
approval.then((p) => ({ type: 'decision' as const, approved: p.approved })),
|
|
162
|
-
sleep('7d').then(() => ({ type: 'timeout' as const })), // [!code highlight]
|
|
163
|
-
]);
|
|
164
|
-
|
|
165
|
-
if (result.type === 'timeout') return { refundId, status: 'timed-out' };
|
|
166
|
-
if (!result.approved) return { refundId, status: 'rejected' };
|
|
167
|
-
return { refundId, status: 'approved' };
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
<Callout type="info">
|
|
171
|
-
Event matching disappears. A hook's token encodes the routing (for example, `refund:${refundId}:approval`), and the caller supplies that token to `resumeHook()`.
|
|
172
|
-
</Callout>
|
|
173
|
-
|
|
174
|
-
## Spawn a child workflow
|
|
175
|
-
|
|
176
|
-
`step.invoke()` splits into spawn and collect. In v5, call `start()` directly from the workflow to spawn the child. Wrap `getRun()` and `returnValue` access in a `"use step"` function when you need to collect the result. Returning the `Run` object from `start()` lets observability deep-link into the child run.
|
|
177
|
-
|
|
178
|
-
You can return either the full `Run` object (enables deep-linking) or just `run.runId` (simpler).
|
|
179
|
-
|
|
180
|
-
{/* @skip-typecheck: snippet without imports */}
|
|
181
|
-
```typescript title="workflow/workflows/parent.ts"
|
|
182
|
-
async function collectResult(runId: string) {
|
|
183
|
-
'use step';
|
|
184
|
-
const run = getRun(runId);
|
|
185
|
-
return await run.returnValue; // [!code highlight]
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export async function parentWorkflow(item: string) {
|
|
189
|
-
'use workflow';
|
|
190
|
-
const child = await start(childWorkflow, [item]); // [!code highlight]
|
|
191
|
-
return await collectResult(child.runId);
|
|
192
|
-
}
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## What you stop operating
|
|
196
|
-
|
|
197
|
-
Dropping the Inngest SDK removes several moving parts:
|
|
198
|
-
|
|
199
|
-
- **No SDK client or serve handler.** Workflow files carry directive annotations. No registry, no serve endpoint.
|
|
200
|
-
- **No event bus.** `start()` launches workflows directly from API routes, server actions, or other entry points. No event schemas or dispatch layer.
|
|
201
|
-
- **No inline step closures.** Steps are named async functions. They type-check and test like any other TypeScript function.
|
|
202
|
-
- **No separate streaming transport.** `getWritable()` delivers progress to clients without WebSockets or SSE glue.
|
|
203
|
-
- **No idle workers.** Workflows suspended on `sleep()` or a hook consume no compute until resumed.
|
|
204
|
-
|
|
205
|
-
## Step-by-step first migration
|
|
206
|
-
|
|
207
|
-
Pick one Inngest function and migrate it end-to-end before touching the rest. The steps below describe the smallest viable path.
|
|
208
|
-
|
|
209
|
-
### Step 1: Install the Workflow SDK
|
|
210
|
-
|
|
211
|
-
Install the SDK. Framework integrations (`workflow/next`, `workflow/nitro`, `workflow/nuxt`, etc.) are subpath exports of the same `workflow` package — no additional install needed.
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
pnpm add workflow
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
### Step 2: Convert `createFunction` to a `"use workflow"` export
|
|
218
|
-
|
|
219
|
-
Replace the factory call with a plain async export. Move the handler body up. The event-binding argument goes away.
|
|
220
|
-
|
|
221
|
-
```ts title="workflows/order.ts"
|
|
222
|
-
// Before (Inngest)
|
|
223
|
-
// export const processOrder = inngest.createFunction(
|
|
224
|
-
// { id: "process-order", triggers: { event: "order/created" } },
|
|
225
|
-
// async ({ event, step }) => { ... }
|
|
226
|
-
// );
|
|
227
|
-
|
|
228
|
-
// After (Workflow SDK)
|
|
229
|
-
export async function processOrder(orderId: string) {
|
|
230
|
-
"use workflow"; // [!code highlight]
|
|
231
|
-
// ...
|
|
232
|
-
}
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### Step 3: Convert `step.run` callbacks into named step functions
|
|
236
|
-
|
|
237
|
-
Each inline callback becomes a named function with `"use step"` on the first line. The workflow calls them with a plain `await`.
|
|
238
|
-
|
|
239
|
-
```ts
|
|
240
|
-
async function loadOrder(id: string) {
|
|
241
|
-
"use step"; // [!code highlight]
|
|
242
|
-
return fetch(`https://example.com/api/orders/${id}`).then((r) => r.json());
|
|
243
|
-
}
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
Configure per-step retry counts by assigning `maxRetries` as a function property:
|
|
247
|
-
|
|
248
|
-
```ts
|
|
249
|
-
async function callApi(endpoint: string) {
|
|
250
|
-
"use step";
|
|
251
|
-
const response = await fetch(endpoint);
|
|
252
|
-
return response.json();
|
|
253
|
-
}
|
|
254
|
-
callApi.maxRetries = 5;
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
See [Errors and retries](/docs/foundations/errors-and-retries) for full retry docs.
|
|
258
|
-
|
|
259
|
-
### Step 4: Replace `waitForEvent`, `sleep`, and `invoke`
|
|
260
|
-
|
|
261
|
-
- `step.waitForEvent(...)` → `createHook({ token })` + `await hook`. Resume it from an API route with `resumeHook(token, payload)`.
|
|
262
|
-
- `step.sleep(...)` → `sleep("5m")` from `workflow`.
|
|
263
|
-
- `step.invoke(child, { data })` → call `start(child, [data])` from the workflow, and optionally read its return value from a step with `getRun(run.runId).returnValue`.
|
|
264
|
-
|
|
265
|
-
### Step 5: Start runs from the app
|
|
266
|
-
|
|
267
|
-
Delete the `serve()` handler and event dispatch. Launch runs directly from an API route:
|
|
268
|
-
|
|
269
|
-
```ts title="app/api/orders/route.ts"
|
|
270
|
-
import { start } from "workflow/api";
|
|
271
|
-
import { processOrder } from "@/workflows/order";
|
|
272
|
-
|
|
273
|
-
export async function POST(req: Request) {
|
|
274
|
-
const { orderId } = await req.json();
|
|
275
|
-
const run = await start(processOrder, [orderId]);
|
|
276
|
-
return Response.json({ runId: run.runId });
|
|
277
|
-
}
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### Step 6: Retire the Inngest infrastructure
|
|
281
|
-
|
|
282
|
-
Remove the `inngest` client, the `serve()` route, event schemas, and the Inngest Dev Server from the app. Verify the run in `npx workflow web` before shipping.
|
|
283
|
-
|
|
284
|
-
## Features without a 1:1 equivalent
|
|
285
|
-
|
|
286
|
-
- **Cron / scheduled functions (`triggers: { cron: '...' }`).** The SDK has no built-in scheduler. Trigger runs from Vercel Cron or a system cron calling `start()` from an API route.
|
|
287
|
-
- **Concurrency, throttling, rate limiting, debounce, singleton, priority, and `batchEvents`.** These function-level settings have no direct analog. Enforce limits inside steps (semaphores, external rate-limiter service) or debounce at the publisher before calling `start()`.
|
|
288
|
-
- **`EventSchemas` / typed events.** The event-bus indirection goes away; publishers import the workflow function directly, giving the same type safety through a different mechanism.
|
|
289
|
-
- **Event-bus fan-out by name match.** `inngest.send()` that triggered multiple functions by event name must be replaced by explicit `start()` calls for each target workflow.
|
|
290
|
-
|
|
291
|
-
## Quick-start checklist
|
|
292
|
-
|
|
293
|
-
- Replace `inngest.createFunction()` with a `"use workflow"` function; launch it with `start()`.
|
|
294
|
-
- Convert each `step.run()` callback into a named `"use step"` function.
|
|
295
|
-
- Swap `step.sleep()` / `step.sleepUntil()` for `sleep()` from `workflow`.
|
|
296
|
-
- Swap `step.waitForEvent()` for `createHook()` (internal) or `createWebhook()` (HTTP).
|
|
297
|
-
- Model `waitForEvent` timeouts as `Promise.race()` between the hook and `sleep()`.
|
|
298
|
-
- Replace `step.invoke()` with direct `start()` calls and a `"use step"` wrapper around `getRun()` when collecting results.
|
|
299
|
-
- Replace `step.sendEvent()` fan-out with explicit `start()` calls.
|
|
300
|
-
- Remove the Inngest client, `serve()` handler, and event definitions.
|
|
301
|
-
- Push retry configuration down to step boundaries via `maxRetries`, `RetryableError`, and `FatalError`.
|
|
302
|
-
- Use `getStepMetadata().stepId` as the idempotency key for external side effects.
|
|
303
|
-
- Replace `step.realtime.publish()` with `getWritable()`.
|
|
304
|
-
- Deploy and verify end-to-end with the built-in observability UI.
|
|
305
|
-
|
|
306
|
-
---
|
|
307
|
-
|
|
308
|
-
*Verified against `workflow@5.0.0-beta.1` and Inngest TypeScript SDK v4 on 2026-04-16.*
|