workflow 5.1.0 → 5.2.1

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/README.md CHANGED
@@ -65,6 +65,12 @@ Choose your framework in the
65
65
 
66
66
  ## Run anywhere
67
67
 
68
+ For application-level completion and failure reporting, `registerLifecycleHooks`
69
+ from `workflow/api` registers handlers in the workflow executor's host startup.
70
+ Calling it inside a workflow or step throws. Check the
71
+ [lifecycle hooks guide](https://workflow-sdk.dev/docs/observability/lifecycle-hooks)
72
+ for supported framework/deployment combinations and stream cleanup requirements.
73
+
68
74
  Local development uses the bundled backend with no configuration. Deploy to
69
75
  Vercel for managed storage, queuing, scaling, and observability. To self-host,
70
76
  use the Postgres backend or implement a custom
@@ -1 +1 @@
1
- {"version":3,"file":"api-workflow.d.ts","sourceRoot":"","sources":["../src/api-workflow.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAChB,KAAK,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,6BAA6B,EAC7B,WAAW,EACX,gCAAgC,GACjC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAQrD,eAAO,MAAM,MAAM,aAA+B,CAAC;AACnD,eAAO,MAAM,cAAc,aAAuC,CAAC;AACnE,eAAO,MAAM,UAAU,aAAmC,CAAC;AAC3D,eAAO,MAAM,aAAa,aAAsC,CAAC;AACjE,eAAO,MAAM,OAAO,aAAgC,CAAC;AACrD,eAAO,MAAM,sBAAsB,aACK,CAAC;AACzC,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,wCAAwC,CAAC"}
1
+ {"version":3,"file":"api-workflow.d.ts","sourceRoot":"","sources":["../src/api-workflow.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAChB,KAAK,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,6BAA6B,EAC7B,WAAW,EACX,gCAAgC,GACjC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAQrD,eAAO,MAAM,MAAM,aAA+B,CAAC;AACnD,eAAO,MAAM,cAAc,aAAuC,CAAC;AACnE,eAAO,MAAM,UAAU,aAAmC,CAAC;AAC3D,eAAO,MAAM,aAAa,aAAsC,CAAC;AACjE,eAAO,MAAM,OAAO,aAAgC,CAAC;AACrD,eAAO,MAAM,sBAAsB,aAIlC,CAAC;AACF,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,wCAAwC,CAAC"}
@@ -8,5 +8,7 @@ export const getHookByToken = () => workflowStub('getHookByToken');
8
8
  export const resumeHook = () => workflowStub('resumeHook');
9
9
  export const resumeWebhook = () => workflowStub('resumeWebhook');
10
10
  export const runStep = () => workflowStub('runStep');
11
- export const registerLifecycleHooks = () => workflowStub('registerLifecycleHooks');
12
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLXdvcmtmbG93LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2FwaS13b3JrZmxvdy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFXQSxPQUFPLEVBQUUsR0FBRyxFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFDakQsT0FBTyxFQUFFLEtBQUssRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBRXJELE1BQU0sWUFBWSxHQUFHLENBQUMsSUFBWSxFQUFFLEVBQUU7SUFDcEMsTUFBTSxJQUFJLEtBQUssQ0FDYixnRUFBZ0UsSUFBSSwyRkFBMkYsQ0FDaEssQ0FBQztBQUNKLENBQUMsQ0FBQztBQUVGLE1BQU0sQ0FB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leHooks must be called at host startup, not inside a workflow or step function. Register before handling workflow requests (for example, in instrumentation.ts on Next.js).');
13
+ };
14
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLXdvcmtmbG93LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2FwaS13b3JrZmxvdy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFXQSxPQUFPLEVBQUUsR0FBRyxFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFDakQsT0FBTyxFQUFFLEtBQUssRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBRXJELE1BQU0sWUFBWSxHQUFHLENBQUMsSUFBWSxFQUFFLEVBQUU7SUFDcEMsTUFBTSxJQUFJLEtBQUssQ0FDYixnRUFBZ0UsSUFBSSwyRkFBMkYsQ0FDaEssQ0FBQztBQUNKLENBQUMsQ0FBQztBQUVGLE1BQU0sQ0FBQyxNQUFNLE1BQU0sR0FBRyxHQUFHLEVBQUUsQ0FBQyxZQUFZLENBQUMsUUFBUSxDQUFDLENBQUM7QUFDbkQsTUFBTSxDQUFDLE1BQU0sY0FBYyxHQUFHLEdBQUcsRUFBRSxDQUFDLFlBQVksQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFDO0FBQ25FLE1BQU0sQ0FBQyxNQUFNLFVBQVUsR0FBRyxHQUFHLEVBQUUsQ0FBQyxZQUFZLENBQUMsWUFBWSxDQUFDLENBQUM7QUFDM0QsTUFBTSxDQUFDLE1BQU0sYUFBYSxHQUFHLEdBQUcsRUFBRSxDQUFDLFlBQVksQ0FBQyxlQUFlLENBQUMsQ0FBQztBQUNqRSxNQUFNLENBQUMsTUFBTSxPQUFPLEdBQUcsR0FBRyxFQUFFLENBQUMsWUFBWSxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQ3JELE1BQU0sQ0FBQyxNQUFNLHNCQUFzQixHQUFHLEdBQUcsRUFBRTtJQUN6Qy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G93U3R1YigncmVzdW1lSG9vaycpO1xuZXhwb3J0IGNvbnN0IHJlc3VtZVdlYmhvb2sgPSAoKSA9PiB3b3JrZmxvd1N0dWIoJ3Jlc3VtZVdlYmhvb2snKTtcbmV4cG9ydCBjb25zdCBydW5TdGVwID0gKCkgPT4gd29ya2Zsb3dTdHViKCdydW5TdGVwJyk7XG5leHBvcnQgY29uc3QgcmVnaXN0ZXJMaWZlY3ljbGVIb29rcyA9ICgpID0+IHtcbiAgdGhyb3cgbmV3IEVycm9yKFxuICAgICdyZWdpc3RlckxpZmVjeWNsZUhvb2tzIG11c3QgYmUgY2FsbGVkIGF0IGhvc3Qgc3RhcnR1cCwgbm90IGluc2lkZSBhIHdvcmtmbG93IG9yIHN0ZXAgZnVuY3Rpb24uIFJlZ2lzdGVyIGJlZm9yZSBoYW5kbGluZyB3b3JrZmxvdyByZXF1ZXN0cyAoZm9yIGV4YW1wbGUsIGluIGluc3RydW1lbnRhdGlvbi50cyBvbiBOZXh0LmpzKS4nXG4gICk7XG59O1xuZXhwb3J0IHR5cGUge1xuICBSdW5Db21wbGV0ZWRIb29rUGFyYW1zLFxuICBSdW5GYWlsZWRIb29rUGFyYW1zLFxuICBXb3JrZmxvd0xpZmVjeWNsZUhvb2tzLFxufSBmcm9tICdAd29ya2Zsb3cvY29yZS9ydW50aW1lL2xpZmVjeWNsZS1ob29rcyc7XG4iXX0=
@@ -1,2 +1,2 @@
1
- export { EntityConflictError, HookConflictError, HookForceClaimedError, HookNotFoundError, PreconditionFailedError, RunExpiredError, RunNotSupportedError, StepNotRegisteredError, StreamError, ThrottleError, TooEarlyError, WorkflowError, WorkflowNotRegisteredError, WorkflowRunCancelledError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRunNotFoundError, WorkflowRuntimeError, WorkflowWorldError, } from '@workflow/errors';
1
+ export { EntityConflictError, HookConflictError, HookForceClaimedError, HookNotFoundError, InBandSupersededError, PreconditionFailedError, RunExpiredError, RunNotSupportedError, StepNotRegisteredError, StreamError, ThrottleError, TooEarlyError, WorkflowError, WorkflowNotRegisteredError, WorkflowRunCancelledError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRunNotFoundError, WorkflowRuntimeError, WorkflowWorldError, } from '@workflow/errors';
2
2
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/internal/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,WAAW,EACX,aAAa,EACb,aAAa,EACb,aAAa,EACb,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/internal/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,WAAW,EACX,aAAa,EACb,aAAa,EACb,aAAa,EACb,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC"}
@@ -1,2 +1,2 @@
1
- export { EntityConflictError, HookConflictError, HookForceClaimedError, HookNotFoundError, PreconditionFailedError, RunExpiredError, RunNotSupportedError, StepNotRegisteredError, StreamError, ThrottleError, TooEarlyError, WorkflowError, WorkflowNotRegisteredError, WorkflowRunCancelledError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRunNotFoundError, WorkflowRuntimeError, WorkflowWorldError, } from '@workflow/errors';
2
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ZWRFcnJvcixcbiAgV29ya2Zsb3dSdW5Ob3RGb3VuZEVycm9yLFxuICBXb3JrZmxvd1J1bnRpbWVFcnJvcixcbiAgV29ya2Zsb3dXb3JsZEVycm9yLFxufSBmcm9tICdAd29ya2Zsb3cvZXJyb3JzJztcbiJdfQ==
1
+ export { EntityConflictError, HookConflictError, HookForceClaimedError, HookNotFoundError, InBandSupersededError, PreconditionFailedError, RunExpiredError, RunNotSupportedError, StepNotRegisteredError, StreamError, ThrottleError, TooEarlyError, WorkflowError, WorkflowNotRegisteredError, WorkflowRunCancelledError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRunNotFoundError, WorkflowRuntimeError, WorkflowWorldError, } from '@workflow/errors';
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2ludGVybmFsL2Vycm9ycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wsbUJBQW1CLEVBQ25CLGlCQUFpQixFQUNqQixxQkFBcUIsRUFDckIsaUJBQWlCLEVBQ2pCLHFCQUFxQixFQUNyQix1QkFBdUIsRUFDdkIsZUFBZSxFQUNmLG9CQUFvQixFQUNwQixzQkFBc0IsRUFDdEIsV0FBVyxFQUNYLGFBQWEsRUFDYixhQUFhLEVBQ2IsYUFBYSxFQUNiLDBCQUEwQixFQUMxQix5QkFBeUIsRUFDekIsc0JBQXNCLEVBQ3RCLDRCQUE0QixFQUM1Qix3QkFBd0IsRUFDeEIsb0JBQW9CLEVBQ3BCLGtCQUFrQixHQUNuQixNQUFNLGtCQUFrQixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHtcbiAgRW50aXR5Q29uZmxpY3RFcnJvcixcbiAgSG9va0NvbmZsaWN0RXJyb3IsXG4gIEhvb2tGb3JjZUNsYWltZWRFcnJvcixcbiAgSG9va05vdEZvdW5kRXJyb3IsXG4gIEluQmFuZFN1cGVyc2VkZWRFcnJvcixcbiAgUHJlY29uZGl0aW9uRmFpbGVkRXJyb3IsXG4gIFJ1bkV4cGlyZWRFcnJvcixcbiAgUnVuTm90U3VwcG9ydGVkRXJyb3IsXG4gIFN0ZXBOb3RSZWdpc3RlcmVkRXJyb3IsXG4gIFN0cmVhbUVycm9yLFxuICBUaHJvdHRsZUVycm9yLFxuICBUb29FYXJseUVycm9yLFxuICBXb3JrZmxvd0Vycm9yLFxuICBXb3JrZmxvd05vdFJlZ2lzdGVyZWRFcnJvcixcbiAgV29ya2Zsb3dSdW5DYW5jZWxsZWRFcnJvcixcbiAgV29ya2Zsb3dSdW5GYWlsZWRFcnJvcixcbiAgV29ya2Zsb3dSdW5Ob3RDb21wbGV0ZWRFcnJvcixcbiAgV29ya2Zsb3dSdW5Ob3RGb3VuZEVycm9yLFxuICBXb3JrZmxvd1J1bnRpbWVFcnJvcixcbiAgV29ya2Zsb3dXb3JsZEVycm9yLFxufSBmcm9tICdAd29ya2Zsb3cvZXJyb3JzJztcbiJdfQ==
@@ -12,7 +12,9 @@ related:
12
12
 
13
13
  Registers global workflow lifecycle handlers, invoked by the runtime on the compute that records a run's terminal transition. Use it for best-effort centralized reporting, such as forwarding failed runs to Sentry, without wrapping each workflow body.
14
14
 
15
- Register early in the process lifecycle (in Next.js, `instrumentation.ts`) so handlers exist before the first run finishes. See the [lifecycle hooks guide](/docs/observability/lifecycle-hooks) for semantics and a full Sentry example.
15
+ Register in the host process that executes workflows, before it handles requests. In **Next.js 16.3.0 and later**, use `instrumentation.ts` as below. Earlier Next.js versions can process a cold Vercel invocation before async registration finishes. See the [framework support table](/docs/observability/lifecycle-hooks#framework-support) for registration locations and a full Sentry example in the guide.
16
+
17
+ App startup registration does not reach the standalone workflow functions emitted on Vercel by Nuxt 4 / Nitro v2, Astro, Nest, or the CLI `vercel-build-output-api` target. Those targets do not yet support this registration pattern. In Nitro v3, use a static import and synchronous server-plugin registration; Nitro does not await async plugins. Do not register from a workflow file or a step function.
16
18
 
17
19
  ```typescript title="instrumentation.ts" lineNumbers
18
20
  export async function register() {
@@ -36,6 +38,8 @@ export async function register() {
36
38
 
37
39
  Keep the dynamic import inside the `NEXT_RUNTIME === "nodejs"` guard. Next.js also compiles `instrumentation.ts` for the Edge runtime. A top-level static import of `workflow/api` pulls Node.js-only dependencies into that compilation and breaks webpack Edge builds, even if the registration call is guarded.
38
40
 
41
+ Restart `next dev` after editing instrumentation handlers: Next.js memoizes registration per process, so edits may not take effect until restart. Other hot-reloading hosts can re-register in the same process; keep the unregister function in process-wide state across reloads, or restart the server.
42
+
39
43
  ## API Signature
40
44
 
41
45
  ### Parameters
@@ -55,6 +59,8 @@ Returns a function that unregisters these hooks. Registrations are not deduplica
55
59
 
56
60
  Both handlers receive a `workflowName` string and a lazily hydrated [`Run`](/docs/api-reference/workflow-api/get-run) instance. Use the `workflowName` parameter to filter without a backend read; `run.runId` also requires no read. Accessors such as `run.workflowName`, `run.status`, and `run.returnValue` still fetch from the backend when used. In particular, `workflowName` is a string, while `run.workflowName` is a `Promise<string>`. Lazy access defers those reads rather than eliminating them.
57
61
 
62
+ Parameters come from the runtime's module copy, which may differ from the handler's copy in a bundled app. Avoid `instanceof` checks against `Run`, SDK errors, or your own bundled error classes. Use `WorkflowRunFailedError.is(error)` (`workflow/errors`), `FatalError.is(error.cause)` (`workflow`), `error.errorCode`, and the cause's `name` or your own serialized discriminator. See [identifying errors across module copies](/docs/observability/lifecycle-hooks#identifying-errors-across-module-copies) for an example.
63
+
58
64
  ### `onRunCompleted`
59
65
 
60
66
  Invoked when a workflow run completes successfully.
@@ -74,14 +80,18 @@ Invoked when a workflow run fails terminally (after any retries).
74
80
  | `params.workflowName` | `string` | The machine-readable workflow identifier, such as `workflow//./src/workflows/order//processOrder`. Available without a backend read. |
75
81
  | `params.error` | `WorkflowRunFailedError` | The persisted failure hydrated for reporting: `error.errorCode` carries the classification (e.g. `USER_ERROR`) and `error.cause` is the hydrated thrown value. |
76
82
 
77
- Unlike `run.returnValue`, `error.cause` defers readable stream I/O until consumption and revives abort signals as persisted snapshots without live subscriptions. Writable streams retain their normal forwarding pipe and lock-polling setup during hydration. If hydration fails, the cause is a generic `Error`, matching `run.returnValue`'s fallback. In `onRunFailed`, `run.returnValue` rejects because the run failed. Use `error.cause` to inspect or report the thrown value instead.
83
+ Unlike `run.returnValue`, `error.cause` defers readable stream I/O until consumption and revives abort signals as persisted snapshots without live subscriptions. Writable streams retain their normal forwarding setup, and writes still reach the failed run's stream or the parent run's stream for a forwarded writable. Custom serialization revives registered classes using the runtime's module copy; plain user-defined Error subclasses without custom serialization revive as generic errors with their name preserved. If hydration fails, the SDK logs the reason and the cause is a generic `Error`, matching `run.returnValue`'s fallback. In `onRunFailed`, `run.returnValue` rejects because the run failed. Use `error.cause` to inspect or report the thrown value instead.
84
+
85
+ On Vercel, the invocation's `waitUntil` scope drains background stream operations from **`error.cause`**, even after a handler returns or throws. It does not automatically cover pipes from `await run.returnValue` in `onRunCompleted`, or consumption scheduled after the handler returns. Await consumption and other reporting work in your handler. Other hosts may stop detached work when the process freezes or terminates.
78
86
 
79
- The invocation's `waitUntil` scope includes background stream operations from the hydrated cause, even after a handler returns or throws. Close or release stream reader and writer locks when finished so that work can settle. Await other asynchronous reporting work in your handler to keep it in the same lifetime scope.
87
+ <Callout type="warn">
88
+ A stream lock left open can keep the drain and lifecycle span pending until the function's maximum duration. Close or release reader and writer locks when finished; cancel a partially consumed reader in `finally`. See the [stream cleanup example](/docs/observability/lifecycle-hooks#stream-lifetime).
89
+ </Callout>
80
90
 
81
91
  ## Behavior
82
92
 
83
- - Handlers run on the host (full Node.js), never inside the workflow VM. Calling `registerLifecycleHooks` from workflow code throws.
93
+ - Register at host startup. Handlers run on the host (full Node.js), never inside the workflow VM. Calling `registerLifecycleHooks` from workflow or step code throws.
84
94
  - Handlers are fire-and-forget. They cannot delay or change the run's outcome, and the runtime logs and swallows a throwing handler. On Vercel, `waitUntil` keeps the invocation alive while handlers finish, subject to the invocation's duration limit. On other hosts, handlers run as detached work and may not complete if the host freezes or terminates the process after the response.
85
95
  - Delivery is best effort. Each registered handler is invoked at most once by the invocation that writes the terminal event. Callbacks are not retried if they throw or the process dies, so they may never run or may stop before completing. The [event log](/docs/how-it-works/event-sourcing) is the system of record.
86
96
  - Handlers fire only on the invocation that wrote the terminal event. Transitions recorded outside your app's compute (e.g. a run cancelled from the CLI or dashboard) do not fire handlers.
87
- - You can register multiple hook sets, and handlers run in registration order.
97
+ - You can register multiple hook sets, and handlers run in registration order. Registrations are not deduplicated; unregister a previous hook set before registering it again in the same process.
@@ -64,6 +64,7 @@ Learn more about [`WorkflowReadableStreamOptions`](/docs/api-reference/workflow-
64
64
  * `attributes` seeds plaintext run metadata as part of creation and requires a World implementing spec version 4 or later. Keys that start with `$` are reserved for framework and library code; framework-level callers can pass `allowReservedAttributes: true` to seed reserved keys, with the same semantics as the [`setAttributes`](/docs/api-reference/workflow/set-attributes) option of the same name.
65
65
  * `region` pins the new run to a specific region on Worlds with a regional dimension. The [Vercel World](/worlds/vercel#explicit-region-selection) then serves the run's storage, queue dispatch, and streams from that region. When you omit `region`, the run is pinned to the region where it was created. Worlds without regions ignore the option.
66
66
  * `experimental_retention` asks the World to delete the run's user data as soon as the run completes or fails, instead of keeping it for the World's default window. `0` requests immediate deletion; `'default'` is identical to omitting the option. These are the only two values accepted — the value is a duration and zero is the only one implemented, and its unit is not yet decided. Recorded as the reserved `$retention` attribute, so it needs a World implementing spec version 4 or later. Retention is enforced by the World, not the SDK: the first-party Worlds implement it and a World that does not keeps the data. Note that `await run.returnValue` on a run started with `experimental_retention: 0` usually throws [`RunExpiredError`](/docs/errors/run-expired) rather than resolving, because the deletion races the read. See [Data retention](/docs/observability/retention).
67
+ * `compressArguments: false` stores the run's arguments uncompressed. By default they are compressed when the target run can decode them; the attempt costs CPU proportional to the input size and is wasted on data that will not shrink (media, encrypted or random bytes), so skip it when you know the inputs are incompressible. `true` is the default and does not force compression. The option only affects the arguments; a [dynamic workflow's](/docs/advanced/dynamic-workflows) code is compressed regardless. To disable compression for every write in a process, see [`WORKFLOW_DISABLE_COMPRESSION`](/docs/configuration/runtime-tuning#workflow_disable_compression).
67
68
 
68
69
  <Callout type="info">
69
70
  If `start()` throws `'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.`, the compiler did not transform the passed function as a workflow. The two most common causes are a missing `"use workflow"` directive or missing framework integration. See [start-invalid-workflow-function](/docs/errors/start-invalid-workflow-function).
@@ -33,7 +33,7 @@ const parsed = parseStepName("step//./src/workflows/order//processPayment"); //
33
33
 
34
34
  | Property | Description |
35
35
  |----------|-------------|
36
- | `shortName` | The display name: the last segment of the function name. For nested steps like `processOrder/chargeCard`, this is `"chargeCard"`. |
36
+ | `shortName` | The display name: the last segment of the function name. For nested steps like `processOrder/chargeCard`, this is `"chargeCard"`. When same-named nested steps require disambiguation, the generated `~N` suffix is preserved (for example, `"chargeCard~1"`). |
37
37
  | `moduleSpecifier` | The module the step is defined in: a relative path (`./src/workflows/order`) or a package specifier (`@myorg/tasks@2.0.0`). |
38
38
  | `functionName` | The full function name including nesting (e.g. `processOrder/chargeCard`). |
39
39
 
@@ -200,6 +200,7 @@ const result = await world.runs.list({ // [!code highlight]
200
200
  | `params.workflowName` | `string` | Only return runs of this workflow |
201
201
  | `params.status` | `WorkflowRunStatus \| WorkflowRunStatus[]` | Only return runs in this status. Pass an array to match any of the listed statuses; an empty array matches no runs. `@workflow/world-vercel` accepts a single status only and throws `WorkflowWorldError` (`INVALID_ARGUMENT`) for an array |
202
202
  | `params.pagination.cursor` | `string` | Cursor for the next page |
203
+ | `params.pagination.sortOrder` | `"asc" \| "desc"` | Run creation order. Default: `"desc"` (newest first) |
203
204
  | `params.resolveData` | `'all' \| 'none'` | Whether to include input/output data |
204
205
 
205
206
  **Returns:** `{ data: WorkflowRun[], cursor?: string }`
@@ -297,6 +298,7 @@ const result = await world.steps.list({ // [!code highlight]
297
298
  |-----------|------|-------------|
298
299
  | `params.runId` | `string` | Filter steps by run ID |
299
300
  | `params.pagination.cursor` | `string` | Cursor for the next page |
301
+ | `params.pagination.sortOrder` | `"asc" \| "desc"` | Step creation order. Default: `"desc"` (newest first) |
300
302
  | `params.resolveData` | `'all' \| 'none'` | Whether to include input/output data |
301
303
 
302
304
  **Returns:** `{ data: Step[], cursor?: string }`
@@ -62,11 +62,11 @@ The contract:
62
62
 
63
63
  ## The runtime integration (suspension fan-out fold)
64
64
 
65
- **On by default.** The suspension handler folds a **clean fan-out** (the suspension's eager `step_created` and `wait_created` writes) into `createBatch` calls of at most 32 events (mirroring the server's transaction budgets). Chunks of a larger fan-out commit **concurrently**: slot assignment is the World's, so parallel chunks race for slot ranges exactly like the pre-fold path's parallel single writes did, and per-entity conditions, not commit order, carry correctness. The fold only engages when the World implements `createBatch`, the run is on slot identity, and the suspension carries no attribute writes and no resilient step dispatch; everything else keeps the single-event path byte-for-byte. A suspension that also creates or disposes hooks still folds: hook writes are not batchable, so they go through the single-event path **concurrently** with the fold rather than ahead of it.
65
+ **On by default.** The suspension handler folds a **clean fan-out** (the suspension's eager `step_created` and `wait_created` writes) into `createBatch` calls of at most 16 events. The server's transaction budgets allow more; 16 is a latency choice (see **Per-chunk continuation**). Chunks of a larger fan-out commit **concurrently**: slot assignment is the World's, so parallel chunks race for slot ranges exactly like the pre-fold path's parallel single writes did, and per-entity conditions, not commit order, carry correctness. The fold only engages when the World implements `createBatch`, the run is on slot identity, and the suspension carries no attribute writes and no resilient step dispatch; everything else keeps the single-event path byte-for-byte. A suspension that also creates or disposes hooks still folds: hook writes are not batchable, so they go through the single-event path **concurrently** with the fold rather than ahead of it.
66
66
 
67
- **Per-chunk continuation.** Each chunk's follow-on work starts the moment **that chunk** commits, not when the whole fold does: a chunk's step-execution queue messages publish right off its own commit (publish-after-create holds per step), and only the chunk carrying the inline pairs gates the replay's continuation: trailing chunks' commits and publishes are joined before the invocation can acknowledge its message, so the durability contract ("every create durable before ack") is unchanged.
67
+ **Per-chunk continuation.** Each chunk's follow-on work starts the moment **that chunk** commits, not when the whole fold does: a chunk's step-execution queue messages publish right off its own commit (publish-after-create holds per step), and only the chunk carrying the inline pairs gates the replay's continuation: trailing chunks' commits and publishes are joined before the invocation can acknowledge its message, so the durability contract ("every create durable before ack") is unchanged. A queued step's message therefore waits on two hops in series, its chunk's commit and then its chunk's batched publish, and both grow with the chunk's size, so smaller chunks start a wide fan-out's queued branches sooner. More chunks also means more concurrent batch writes per run, and from about 16 of them the pair chunk, and with it the first inline branch, slows down. The 16-event cap is where production measurements balanced the two: on 64- and 128-branch fan-outs the last branch started about 90 to 200 ms sooner than at 32 events, with no first-branch cost at those widths.
68
68
 
69
- **Pre-claimed inline pairs.** When the fold engages with at least two inline steps, the steps the runtime is about to execute inline join the batch as adjacent `[step_created, step_started]` pairs: the created row carrying the input, the started row a bare ownership-stamped claim the World folds into a born-running create. The pairs commit in a chunk of their own, ahead of the plain `step_created` and `wait_created` chunks, so the write the inline bodies wait for carries only two rows per inline step (a small transaction that commits faster than a full 32-event chunk) while the plain creates commit concurrently beside it. The inline bodies start straight off the pair chunk's commit (in parallel with the queue publishes and the sibling chunks) with no per-step claim POST at all, and a pair that loses its atomic create-claim to a concurrent delivery skips its body exactly as a lost lazy claim does. A lone inline step keeps the optimistic lazy-start path (one row, whose claim overlaps the body) even when eager creates batch beside it: the pairs share no round trip with those creates, so only two or more inline steps make a pair chunk worth the trade. The exception is a lone inline step in a suspension that creates a hook: the runtime never starts a body before its claim settles while a hook is being created, and a lazy claim could only be sent after the hook write committed, so the step's pair is folded instead and its claim commits concurrently with the hook write. A plain partition of exactly one `step_created` or `wait_created` beside the pairs is written through the ordinary single path rather than a one-row batch, and its queue message still waits for that write.
69
+ **Pre-claimed inline pairs.** When the fold engages with at least two inline steps, the steps the runtime is about to execute inline join the batch as adjacent `[step_created, step_started]` pairs: the created row carrying the input, the started row a bare ownership-stamped claim the World folds into a born-running create. The pairs commit in a chunk of their own, ahead of the plain `step_created` and `wait_created` chunks, so the write the inline bodies wait for carries only two rows per inline step (a small transaction that commits faster than a full 16-event chunk) while the plain creates commit concurrently beside it. The inline bodies start straight off the pair chunk's commit (in parallel with the queue publishes and the sibling chunks) with no per-step claim POST at all, and a pair that loses its atomic create-claim to a concurrent delivery skips its body exactly as a lost lazy claim does. A lone inline step keeps the optimistic lazy-start path (one row, whose claim overlaps the body) even when eager creates batch beside it: the pairs share no round trip with those creates, so only two or more inline steps make a pair chunk worth the trade. The exception is a lone inline step in a suspension that creates a hook: the runtime never starts a body before its claim settles while a hook is being created, and a lazy claim could only be sent after the hook write committed, so the step's pair is folded instead and its claim commits concurrently with the hook write. A plain partition of exactly one `step_created` or `wait_created` beside the pairs is written through the ordinary single path rather than a one-row batch, and its queue message still waits for that write.
70
70
 
71
71
  Per-event `409`s are tolerated the same way the single path tolerates `EntityConflictError` (a concurrent delivery already created the entity); any other per-event failure fails the suspension write the way a single-path rejection would. A batch carrying a `step_started` (that is, any batch with inline pairs) is **not** retried in-process on a transport blip: a pair's `409` cannot be told apart from the caller's own earlier attempt having committed it, so recovery goes through queue redelivery instead, where the step's ownership stamp routes it back to the same invocation.
72
72
 
@@ -107,7 +107,7 @@ Vercel project and auth settings can often be inferred from `.vercel/project.jso
107
107
 
108
108
  - Environment variable: none
109
109
  - Default: unset
110
- - Pagination cursor for list commands.
110
+ - Pagination cursor for list commands. A `workflow inspect` listing that stops with more rows prints the next page's cursor: in its `--json` page object for `runs`, `hooks`, and `attributes`, and on stderr for `steps`, `events`, and `sleeps`, whose `--json` output is an array.
111
111
 
112
112
  ### `--interactive` / `-i`
113
113
 
@@ -125,12 +125,20 @@ per flag.
125
125
  - Command: `workflow inspect`
126
126
  - Default: unset
127
127
  - Scopes the listing to one run. Required for `steps`, `events`, and `sleeps`; optional for `hooks`. Must be a run ID: `wrun_` followed by a 26-character ULID.
128
+ - Also required to read one step, event, or stream, as in `workflow inspect step <step-id> --runId=<run-id>`: their IDs and names are scoped to their run.
128
129
 
129
130
  ### `--limit` (inspect)
130
131
 
131
132
  - Command: `workflow inspect`
132
133
  - Default: `20`
133
- - Must be an integer between 1 and 100, the smallest page any inspect listing accepts. Larger pages are reachable by paging: pass `--cursor`, or `--interactive` to walk them.
134
+ - Must be an integer between 1 and 100, the smallest page any inspect listing accepts. Larger pages are reachable by paging: pass `--cursor`, `--all` to read every page, or `--interactive` to walk them.
135
+
136
+ ### `--all`
137
+
138
+ - Command: `workflow inspect steps`, `workflow inspect events`, `workflow inspect sleeps`
139
+ - Default: disabled
140
+ - Follows cursors to the last page and prints every row: one table, or with `--json` one array. `--limit` sets the size of each page it fetches and `--cursor` where it starts.
141
+ - Cannot be combined with `--interactive`, an ID, or `--url`/`--web`. The `runs`, `hooks`, and `attributes` listings take `--cursor` instead: their `--json` output carries it.
134
142
 
135
143
  ### `--stepId` / `-s`
136
144
 
@@ -187,8 +195,8 @@ per flag.
187
195
 
188
196
  - Command: `workflow cancel`
189
197
  - Default: unset
190
- - Restricts the batch to one workflow. Expects the generated workflow ID from `workflow inspect runs`, not the short function name.
191
- - Also filters `workflow inspect runs` and `workflow inspect attributes`.
198
+ - Restricts the batch to one workflow. Expects the generated workflow ID from `workflow inspect runs --json`, not the short function name.
199
+ - Also filters `workflow inspect runs` and `workflow inspect attributes`. These also accept the short name the runs table shows, such as `processOrder`: it is looked up among the workflows of the 500 most recent runs (in the `--since` window when given) and replaced by the full name. A short name that more than one of those workflows share is rejected with the candidates, and one that none of them has is used as given.
192
200
 
193
201
  ### `--limit` (cancel)
194
202
 
@@ -239,14 +239,15 @@ For example, a workflow can run a 10-minute inline step even with `WORKFLOW_REPL
239
239
 
240
240
  ### `WORKFLOW_SNAPSHOT_THRESHOLD`
241
241
 
242
- - Default: `0` (disabled)
243
- - Values: non-negative integer
242
+ - Default: `1000` when the QuickJS engine is selected
243
+ - Values: non-negative integer. `0` disables snapshotting.
244
244
  - Experimental. Only used by the QuickJS engine (`WORKFLOW_VM=quickjs`), and only with a World that provides snapshot storage (world-local, world-postgres, and world-vercel do).
245
- - When set above `0`, the runtime persists a **VM-memory snapshot** at a suspension once at least this many events have been processed since the last snapshot. Subsequent invocations restore the VM from the snapshot and replay only the events recorded since, instead of re-executing the workflow from the top against the full event log.
245
+ - When above `0`, the runtime persists a **VM-memory snapshot** at a suspension once at least this many events have been processed since the last snapshot. Subsequent invocations restore the VM from the snapshot and replay only the events recorded since, instead of re-executing the workflow from the top against the full event log.
246
246
  - Short-lived runs below the threshold never pay the snapshot cost; long-running or unbounded runs stop scaling their resume cost with total event-log length. `1` snapshots at every qualifying suspension.
247
247
  - Choosing a value: a restore costs roughly the same regardless of log length (tens of milliseconds to decompress and restore the heap, plus fetching the snapshot), while a full replay grows with the log (tens of milliseconds at a few hundred events, seconds at several thousand). Restoring starts to pay off at a few hundred events, so values in the hundreds suit most long-running workflows. Very low values mostly add snapshot saves to runs that replay quickly anyway.
248
248
  - Snapshots are an optimization, not a source of truth: the event log remains authoritative, and a missing, corrupt, oversized, or incompatible snapshot automatically falls back to a full replay. Snapshots over 32 MB uncompressed are not saved.
249
- - Like `WORKFLOW_VM`, the policy is stamped into the run's `executionContext` at start, so a run keeps the snapshot policy it started with. `start()` rejects an invalid value. An invalid value on the workflow handler disables snapshotting with a warning.
249
+ - Set `0` to opt out and always replay the full event log.
250
+ - Like `WORKFLOW_VM`, an explicitly set policy is stamped into the run's `executionContext` at start, so a run keeps the snapshot policy it started with. Runs without a stamped policy use the handler's value, or the default. `start()` rejects an invalid value. An invalid value on the workflow handler disables snapshotting with a warning.
250
251
  - A snapshot can only be restored by the exact QuickJS engine build that captured it. On Vercel, runs keep executing on the deployment they started on, so deploys don't affect in-flight snapshots. If your deployment serves in-flight runs from new code (for example, a self-hosted rolling update), an upgrade that changes the embedded engine makes every in-flight run fall back to a full replay at its next resume, all at once, before re-snapshotting at its next qualifying suspension. Plan for that one-time replay load when upgrading.
251
252
 
252
253
  What a snapshot contains, and how it is protected:
@@ -293,9 +293,12 @@ Platform-provided values such as `VERCEL_DEPLOYMENT_ID`, `VERCEL_PROJECT_ID`, an
293
293
 
294
294
  - Factory option: none
295
295
  - CLI flag: none
296
- - Default: `http`
297
- - Experimental stream-write transport capability. Set to exactly `ws` to attempt `workflow-stream-ws/v1`. The server authoritatively accepts or declines each upgrade; a decline uses HTTP directly for that writer lifetime. Stream reads remain HTTP and demand-driven.
298
- - This is not tenant rollout policy or a package-version check. HTTP remains the compatibility path. `/websockets/v1` is independent of REST v2/v4 and persisted workflow `specVersion` values.
296
+ - Default: `ws`
297
+ - Stream writes upgrade to a WebSocket (`workflow-stream-ws/v1`). Set to `http` (case-insensitive, surrounding whitespace ignored) to opt out; any other value, including unset, empty, or `ws`, uses the WebSocket. Stream reads always use HTTP.
298
+ - A writer's first two write groups go over HTTP, and the socket opens in the background after that, so no write waits for the upgrade. The server accepts or declines each upgrade; a declined or failed upgrade leaves that writer on HTTP for its lifetime.
299
+ - Ignored when the World is configured with `projectConfig` and routes through the `api-workflow` proxy, which does not forward a WebSocket upgrade, so stream writes stay on HTTP.
300
+ - The server pings idle sockets to keep them open, and the client must answer. The `ws` library the Vercel World uses does so automatically.
301
+ - Each WebSocket message is at most `WORKFLOW_WS_MAX_MESSAGE_BYTES`. Larger write groups are sent as several ordered requests, and a single chunk too large for one message is written over HTTP.
299
302
  - A throttled (429) socket write or close is retried after the server's `Retry-After`, as over HTTP. It moves to HTTP if the connection ends during the wait or the cumulative wait passes 30 seconds.
300
303
 
301
304
  ### `WORKFLOW_DISABLE_ANALYTICS_READS`
@@ -311,7 +314,7 @@ Platform-provided values such as `VERCEL_DEPLOYMENT_ID`, `VERCEL_PROJECT_ID`, an
311
314
  - Default: on
312
315
  - Set to `0` (or `false`) to **disable** batched event writes, the escape hatch that restores the exact prior one-write-per-event path.
313
316
 
314
- When enabled (the default), a suspension's eager `step_created` and `wait_created` writes fold into batched `events.createBatch` calls (one durable write with per-event outcomes) on Worlds that implement the optional batch API. The fold only engages when the World implements `events.createBatch` (the Vercel World does; Local and Postgres do not), the run's spec version supports slot identity (≥ 6), and the suspension carries no attribute writes or resilient step dispatch. Hook writes in the same suspension go through the single-event path concurrently with the batch. Everything else keeps the single-event path unchanged, so disabling is only needed as an operational escape hatch. Batches are capped at 32 events; larger fan-outs commit in successive batches. See the [batched event writes changelog](/docs/changelog/batched-event-writes) for the World API contract.
317
+ When enabled (the default), a suspension's eager `step_created` and `wait_created` writes fold into batched `events.createBatch` calls (one durable write with per-event outcomes) on Worlds that implement the optional batch API. The fold only engages when the World implements `events.createBatch` (the Vercel World does; Local and Postgres do not), the run's spec version supports slot identity (≥ 6), and the suspension carries no attribute writes or resilient step dispatch. Hook writes in the same suspension go through the single-event path concurrently with the batch. Everything else keeps the single-event path unchanged, so disabling is only needed as an operational escape hatch. Batches are capped at 16 events; larger fan-outs commit in several batches at once. See the [batched event writes changelog](/docs/changelog/batched-event-writes) for the World API contract.
315
318
 
316
319
  ### `WORKFLOW_EVENTS_TRANSPORT`
317
320
 
@@ -148,6 +148,14 @@ export async function birthdayWorkflow(
148
148
  - **Add a deadline to any race**: Pair the operation with `sleep("30s").then(() => "timeout" as const)` and check the discriminated result. See [Timeouts](/cookbook/common-patterns/timeouts).
149
149
  - **Mix steps and hooks in a race**: Wait for an external signal, a deadline, or a step result in the same `Promise.race`. The first promise to resolve wins.
150
150
 
151
+ ## Performance
152
+
153
+ The fan-out benchmark measures how quickly a `Promise.all` over 64 steps gets going and finishes: from `start()` until the first branch and the slowest branch start, and from the slowest branch finishing until the code after `Promise.all` runs. The animation shows the branches starting close together and in no fixed order.
154
+
155
+ <MetricVideo metric="fanout" />
156
+
157
+ See [Fan-out](/docs/performance#fan-out-ttfs-ttls-join) on the Performance page for how it's measured and the latest results.
158
+
151
159
  ## Key APIs
152
160
 
153
161
  - [`"use workflow"`](/docs/foundations/workflows-and-steps): Marks the orchestrator function.
@@ -198,6 +198,41 @@ export async function dataCollectionWorkflow() {
198
198
 
199
199
  Each time you call `resumeHook()` with the same token, the loop receives another value.
200
200
 
201
+ ### Waiting with a timeout
202
+
203
+ Race a hook against `sleep()` to stop waiting after a deadline. To wait again after a timeout, create the hook's promise once and race that same promise on every attempt:
204
+
205
+ ```typescript lineNumbers
206
+ import { createHook, sleep } from "workflow";
207
+
208
+ declare function sendReminder(): Promise<void>; // @setup
209
+
210
+ export async function reminderWorkflow() {
211
+ "use workflow";
212
+
213
+ using hook = createHook<{ approved: boolean }>();
214
+ const approval = hook.then((payload) => payload); // [!code highlight]
215
+
216
+ for (let reminder = 0; reminder < 3; reminder++) {
217
+ const result = await Promise.race([
218
+ approval, // [!code highlight]
219
+ sleep("1d").then(() => "timeout" as const),
220
+ ]);
221
+
222
+ if (result !== "timeout") {
223
+ return result.approved;
224
+ }
225
+ await sendReminder();
226
+ }
227
+
228
+ return false;
229
+ }
230
+ ```
231
+
232
+ Racing a fresh `hook.then()` on each attempt also receives an event that arrives while that race is running. An event that arrives between races, for example while `sendReminder()` runs, is delivered to the awaiter left behind by the earlier race, so the workflow never sees it. Don't race `iterator.next()` from `hook[Symbol.asyncIterator]()` either. The `next()` call that lost a race keeps waiting and takes the next event, even one that arrives while a later race is running. Race the promise you created once instead.
233
+
234
+ Don't await one hook from several places at the same time, for example `Promise.all([hook, hook])`. Which event each await receives depends on how far the workflow had replayed when it awaited, so it can differ between code that looks equivalent. To receive successive events, await them one after another or iterate with `for await...of`.
235
+
201
236
  ### Disposing hooks early
202
237
 
203
238
  When a workflow ends, hooks are automatically disposed. However, you may want to release a hook token early so another workflow can use it while your workflow continues running. Use a block scope with `using` to control when disposal happens:
@@ -635,6 +670,14 @@ for await (const event of hook) {
635
670
 
636
671
  This pattern allows a single workflow instance to handle multiple events over time, maintaining state between events.
637
672
 
673
+ ## Performance
674
+
675
+ Time to resume (TTR) measures how quickly a workflow that is waiting on a hook continues once your app calls `resumeHook()`: the clock starts at that call and stops when the first line of the workflow's next step runs. The animation shows where it starts and stops in a run.
676
+
677
+ <MetricVideo metric="resume" />
678
+
679
+ See [Time to resume](/docs/performance#time-to-resume-ttr) on the Performance page for how it's measured and the latest results.
680
+
638
681
  ## Related documentation
639
682
 
640
683
  - [Serialization](/docs/foundations/serialization) - Understanding what data can be passed through hooks
@@ -59,6 +59,21 @@ These types have special handling and are explained in detail in the sections be
59
59
  - `AbortController`
60
60
  - `AbortSignal`
61
61
 
62
+ ### Typing serializable values
63
+
64
+ Import the `Serializable` type from `workflow` to type values that cross a workflow or step boundary:
65
+
66
+ ```typescript title="workflows/record-event.ts" lineNumbers
67
+ import type { Serializable } from "workflow";
68
+
69
+ async function recordEvent(payload: Serializable) {
70
+ "use step";
71
+ // ...
72
+ }
73
+ ```
74
+
75
+ `Serializable` is a union of the JSON and built-in types listed above. It doesn't include `Request`, `Float16Array`, or classes with [custom serialization](#custom-class-serialization), so type those values directly.
76
+
62
77
  ## Pass-by-value semantics
63
78
 
64
79
  **Parameters are passed by value, not by reference.** Steps receive deserialized copies of data. Mutations inside a step won't affect the original in the workflow.
@@ -289,6 +289,14 @@ export async function syncDashboard() {
289
289
 
290
290
  By default a chained run starts on the same deployment as its parent. For workflows that chain over long periods, pass [`deploymentId: "latest"`](/docs/api-reference/workflow-api/start#using-deploymentid-latest) so the next run picks up new code. [Versioning](/docs/foundations/versioning#self-upgrading-workflows) covers this pattern in full, including how the serialized state acts as the migration boundary between versions.
291
291
 
292
+ ## Performance
293
+
294
+ Time to first step (TTFS) measures how long a new run takes to get going: from your app calling `start()` until the first line of the workflow's first step runs. The animation shows the run being created, the workflow running up to its first step, and that step starting.
295
+
296
+ <MetricVideo metric="ttfs" />
297
+
298
+ See [Time to first step](/docs/performance#time-to-first-step-ttfs) on the Performance page for how it's measured and the latest results.
299
+
292
300
  ## Next steps
293
301
 
294
302
  - Browse the [Cookbook](/cookbook) for copy-paste recipes covering composition, scheduling, timeouts, and more
@@ -635,6 +635,14 @@ export async function streamErrorWorkflow() {
635
635
  Stream errors don't trigger automatic retries for the producer step. Design your stream consumers to handle errors. Because the stream is already in an errored state, retrying the consumer won't help. Use `FatalError` to fail the workflow immediately.
636
636
  </Callout>
637
637
 
638
+ ## Performance
639
+
640
+ Chunk trip time (CTT) measures how quickly a chunk written to a stream reaches its reader: the clock starts when one step writes the chunk and stops when another step receives it. The animation shows a writer step replaying a recorded agent stream and a reader step receiving each chunk.
641
+
642
+ <MetricVideo metric="stream" />
643
+
644
+ See [Chunk trip time](/docs/performance#chunk-trip-time-ctt) on the Performance page for how it's measured and the latest results.
645
+
638
646
  ## Related documentation
639
647
 
640
648
  - [`getWritable()` API reference](/docs/api-reference/workflow/get-writable): Get the workflow's writable stream
@@ -81,7 +81,8 @@ This keeps the version boundary visible. The old run ends as canceled or failed,
81
81
  # Inspect affected runs and copy the exact workflowName value.
82
82
  npx workflow inspect runs \
83
83
  --backend vercel \
84
- --status running
84
+ --status running \
85
+ --json
85
86
 
86
87
  # Cancel one run.
87
88
  npx workflow cancel <run-id> \
@@ -94,7 +95,7 @@ npx workflow cancel \
94
95
  --backend vercel
95
96
  ```
96
97
 
97
- The `--workflowName` filter expects the generated workflow ID, not only the exported function's short name. Use the `workflowName` value from `workflow inspect runs`, and use [`parseWorkflowName()`](/docs/api-reference/workflow-observability/parse-workflow-name) when you need display-friendly names.
98
+ The `workflow cancel --workflowName` filter expects the generated workflow ID, not only the exported function's short name. Copy the `workflowName` value from `workflow inspect runs --json`, since the runs table shows the short name, and use [`parseWorkflowName()`](/docs/api-reference/workflow-observability/parse-workflow-name) when you need display-friendly names.
98
99
 
99
100
  In the [observability UI](/docs/observability), use **Rerun on latest** to enqueue the workflow again with the same inputs against the latest deployment.
100
101
 
@@ -207,7 +207,7 @@ Events are categorized by the entity type they affect. Each event contains metad
207
207
 
208
208
  Counting the events above is how you size a run. A step that succeeds on the first attempt contributes three events; a retry adds another `step_started`, preceded by a `step_retrying` when the World emits one; a sleep contributes two, and a hook at least two.
209
209
 
210
- A run's log is capped — the [Vercel World](/worlds/vercel#per-run-limits) fails anything past its ceiling with `MAX_EVENTS_EXCEEDED`. Replay reads the whole log, so a run gets slower as it grows and is worth splitting well before it fails: split into [child workflows](/cookbook/advanced/child-workflows) once a run would grow past a few thousand events.
210
+ A run's log is capped — the [Vercel World](/worlds/vercel#per-run-limits) fails anything past its ceiling with `MAX_EVENTS_EXCEEDED`. Replay reads the whole log, so a run gets slower as it grows and is worth splitting well before it fails: split into [child workflows](/cookbook/advanced/child-workflows) once a run would grow past a few thousand events. How much the growth costs depends on how often the run replays; [Steps and long runs](/docs/performance#steps-and-long-runs) shows how step-to-step overhead changes through a 1,020-step run.
211
211
 
212
212
  ## Terminal states
213
213
 
@@ -373,3 +373,11 @@ An event ID is a **slot number**: the event's 1-based position in the run's even
373
373
  Density is what lets a reader tell a complete log from an incomplete one by its length alone. A replay that loads a log with a position missing below the highest one it can see cannot tell an event that was never written from one it failed to read, so it fails the run with [`CORRUPTED_EVENT_LOG`](/docs/errors/corrupted-event-log) rather than replay across the hole. See [`WORKFLOW_SLOT_GAP_CHECK`](/docs/configuration/runtime-tuning#workflow_slot_gap_check).
374
374
 
375
375
  A slot ID carries no timestamp. Zero-padded decimal digits are a subset of the ULID alphabet, so a slot ID passes ULID validation and sorts correctly, but decoding its first 48 bits yields the Unix epoch instead of a creation time. Read `createdAt` on the event when you need to know when it was written, and don't decode the time from an `evnt_` ID you get back from an API, a log line, or a cursor.
376
+
377
+ ## Performance
378
+
379
+ Step-to-step overhead (STSO) measures the time the runtime adds between two steps: from one step finishing until the next one starts, which covers recording the step's result, resuming the workflow, and starting the next step. The work inside each step isn't counted. The animation shows where that gap starts and stops.
380
+
381
+ <MetricVideo metric="stso" />
382
+
383
+ See [Step-to-step overhead](/docs/performance#step-to-step-overhead-stso) on the Performance page for how it's measured and the latest results.
package/docs/meta.json CHANGED
@@ -7,6 +7,7 @@
7
7
  "how-it-works",
8
8
  "advanced",
9
9
  "observability",
10
+ "performance",
10
11
  "ai",
11
12
  "testing",
12
13
  "deploying",
@@ -15,7 +15,24 @@ Lifecycle hooks let you register global handlers that observe workflow runs comp
15
15
 
16
16
  ## Registering hooks
17
17
 
18
- Call `registerLifecycleHooks` from `workflow/api` early in your application's lifecycle, so the handlers exist before the first run finishes. In Next.js, [`instrumentation.ts`](https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation) is the natural place; in any other app, any module that loads at startup works.
18
+ Call `registerLifecycleHooks` from `workflow/api` in the **host process that executes workflows**, before it handles requests. Registering in a different server or Vercel Function does not populate the executor's registry.
19
+
20
+ ### Framework support
21
+
22
+ | Integration / deployment | Where to register | Limitations |
23
+ | --- | --- | --- |
24
+ | Next.js 16.3.0 and later | [`instrumentation.ts`](https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation), using the guarded dynamic import below | Earlier Next.js versions can handle a cold Vercel invocation before async instrumentation finishes, skipping hooks. Upgrade to 16.3.0 or later for this pattern. |
25
+ | SvelteKit | `init` in `src/hooks.server.ts`, before serving requests | Re-running initialization during hot reload can append duplicate registrations. |
26
+ | Nitro v3, including the Nitro-based Vite, TanStack Start, Express, Hono, and Fastify integrations | A server plugin with a static import and synchronous registration | Nitro does not await async plugin registration. Do not copy the Next.js dynamic-import pattern into a Nitro plugin. Vite server reloads can re-run plugins in the same process. |
27
+ | Nuxt 4 / Nitro v2 with the Vercel preset | App startup registration is not supported for lifecycle hooks on this target | The generated standalone workflow function does not load Nitro app plugins. |
28
+ | Astro on Vercel | App startup registration is not supported for lifecycle hooks on this target | The generated standalone workflow function does not load Astro middleware. |
29
+ | Nest on Vercel | App startup registration is not supported for lifecycle hooks on this target | The generated standalone workflow function does not load Nest bootstrap code. |
30
+ | CLI `vercel-build-output-api` target | App startup registration is not supported for lifecycle hooks on this target | The generated standalone workflow function does not load the application's startup module. |
31
+ | A shared Node.js server on other hosts | Bootstrap before accepting requests | The bootstrap must run in every process serving workflow queue handlers. |
32
+
33
+ The unsupported Vercel targets above emit a separate `.well-known/workflow/v1/flow.func`. App-startup hooks never reach it, so callbacks do not fire there. Do not work around this by registering at the top level of a workflow file: its VM bundle resolves `workflow/api` to a throwing stub. Registration inside a step also throws; it would otherwise accumulate a handler on every execution.
34
+
35
+ ### Next.js registration
19
36
 
20
37
  ```typescript title="instrumentation.ts" lineNumbers
21
38
  export async function register() {
@@ -41,6 +58,8 @@ Keep the dynamic `workflow/api` import inside the `NEXT_RUNTIME === "nodejs"` gu
41
58
 
42
59
  `registerLifecycleHooks` returns an unregister function. You can register multiple hook sets, and handlers run in registration order. Registrations are not deduplicated: register each hook set once per process, and call its unregister function before registering it again during hot reload or module re-evaluation. Otherwise, repeated registrations invoke the same handler multiple times for each transition.
43
60
 
61
+ **Restart `next dev` after changing handlers registered by `instrumentation.ts`.** Next.js memoizes instrumentation registration per process, so edits may not take effect until restart. For other hot-reloading hosts, preserve the unregister function in process-wide state across module re-evaluation, or restart the server. A module-local variable may be reset by the reload.
62
+
44
63
  ## Handler parameters
45
64
 
46
65
  Both handlers receive a `workflowName` string and the [`Run`](/docs/api-reference/workflow-api/get-run) instance for the transitioned run. `workflowName` is the machine-readable workflow identifier, such as `workflow//./src/workflows/order//processOrder`. Use this parameter to filter runs without a backend read. `run.runId` is also available without a read.
@@ -50,11 +69,56 @@ The `Run` instance hydrates lazily. Accessors such as `run.workflowName`, `run.s
50
69
  `onRunFailed` additionally receives a `WorkflowRunFailedError` hydrated for reporting. Unlike `run.returnValue`, it defers readable stream I/O and uses persisted abort snapshots:
51
70
 
52
71
  - `error.errorCode`: the failure classification (`USER_ERROR`, `RUNTIME_ERROR`, `MAX_DELIVERIES_EXCEEDED`, and more). See [error codes](/docs/errors) for the full list.
53
- - `error.cause`: the thrown value hydrated from the persisted error data, with registered Error subclass identity, message, stack, and cause chain preserved. Readable streams load lazily when consumed, and abort signals reflect their persisted state without live subscriptions. Writable streams retain their normal forwarding pipe and lock-polling setup during hydration. If hydration fails, the cause is a generic `Error`, matching `run.returnValue`'s fallback. Any JavaScript value can be thrown, so this is typed `unknown`.
72
+ - `error.cause`: the thrown value hydrated from the persisted error data, including its message, stack, and cause chain. Custom serialization revives registered classes using the runtime's module copy; constructor identity may differ from the handler's copy. Plain user-defined Error subclasses without custom serialization revive as generic errors with their name preserved. Readable streams load lazily when consumed, and abort signals reflect their persisted state without live subscriptions. Writable streams retain their normal forwarding setup: **writes still reach the failed run's stream, or the parent run's stream for a forwarded writable**. If hydration fails, the SDK logs the reason and supplies a generic `Error`, matching `run.returnValue`'s fallback. Any JavaScript value can be thrown, so this is typed `unknown`.
54
73
 
55
74
  In `onRunFailed`, `run.returnValue` rejects because the run failed. Use `error.cause` to inspect or report the thrown value instead of awaiting `run.returnValue`.
56
75
 
57
- The invocation's `waitUntil` scope includes background stream operations from the hydrated cause, even after a handler returns or throws. Close or release stream reader and writer locks when finished so that work can settle. Await other asynchronous reporting work in your handler, such as `Sentry.flush()` below, to keep it in the same lifetime scope.
76
+ ### Identifying errors across module copies
77
+
78
+ Handler parameters come from the runtime's module copy. For example, Next.js bundles instrumentation separately from app routes. The shared registry connects those copies, but `run instanceof Run`, `error instanceof WorkflowRunFailedError`, and checks against custom error constructors can be false. Use `WorkflowRunFailedError.is(error)` and `FatalError.is(error.cause)` for SDK errors, and inspect `errorCode`, the cause's `name`, or your own serialized discriminator for application errors:
79
+
80
+ ```typescript title="report-failure.ts" lineNumbers
81
+ import { FatalError } from "workflow";
82
+ import { WorkflowRunFailedError } from "workflow/errors";
83
+
84
+ export function reportFailure(error: unknown) {
85
+ if (!WorkflowRunFailedError.is(error)) return;
86
+ const cause = error.cause;
87
+ const name = typeof cause === "object" && cause !== null && "name" in cause
88
+ ? cause.name
89
+ : undefined;
90
+ console.error({ errorCode: error.errorCode, name, fatal: FatalError.is(cause) });
91
+ }
92
+ ```
93
+
94
+ Load this reporting module from the host registration module, using the guarded dynamic import on Next.js.
95
+
96
+ ### Stream lifetime
97
+
98
+ On Vercel, the invocation's `waitUntil` scope drains background stream operations from **`error.cause`**, even after a handler returns or throws. This does not automatically cover pipes from `await run.returnValue` in `onRunCompleted`, or consumption scheduled after the handler returns with timers or other detached work. Await consumption and other asynchronous reporting work in the handler, such as `Sentry.flush()` below. Other hosts run handlers as detached work and may stop them when the process freezes or terminates.
99
+
100
+ <Callout type="warn">
101
+ A readable or writable lock left open can keep the drain and lifecycle span pending until the Vercel Function's maximum duration. Close or release locks when finished. If you only need part of a readable, cancel its reader in a `finally` block:
102
+ </Callout>
103
+
104
+ ```typescript lineNumbers
105
+ import type { RunFailedHookParams } from "workflow/api";
106
+
107
+ async function onRunFailed({ error }: RunFailedHookParams) {
108
+ if (!(error.cause instanceof ReadableStream)) return;
109
+ const reader = error.cause.getReader();
110
+ try {
111
+ const first = await reader.read();
112
+ console.error(first.value);
113
+ } finally {
114
+ try {
115
+ await reader.cancel();
116
+ } finally {
117
+ reader.releaseLock();
118
+ }
119
+ }
120
+ }
121
+ ```
58
122
 
59
123
  ## Reporting failed runs to Sentry
60
124
 
@@ -88,8 +152,8 @@ export async function register() {
88
152
 
89
153
  ## How handlers behave
90
154
 
91
- - **Host-only.** Handlers run with full Node.js access, never inside the workflow's sandboxed VM. Calling `registerLifecycleHooks` from workflow code throws.
155
+ - **Host startup only.** Handlers run with full Node.js access, never inside the workflow's sandboxed VM. Calling `registerLifecycleHooks` from workflow or step code throws.
92
156
  - **Fire-and-forget.** Handlers cannot delay or change the run's outcome. The runtime logs and swallows a throwing handler, and the remaining handlers still run. On Vercel, `waitUntil` keeps the invocation alive while handlers finish, subject to the invocation's duration limit. On other hosts, handlers run as detached work. If the host freezes or terminates the process after the response, handlers may not complete.
93
157
  - **Best-effort delivery.** Each registered handler is invoked at most once by the invocation that writes the terminal event. For a failure, this happens after any workflow or step retries are exhausted. Callbacks are not retried if they throw or the process dies, so a callback may never run or may stop before completing. The [event log](/docs/how-it-works/event-sourcing) is the system of record, not lifecycle callbacks.
94
158
  - **Fires where the transition is recorded.** Terminal transitions recorded outside your app's compute do **not** fire handlers. For example, when you cancel a run from the CLI or the Vercel dashboard, the backend writes that transition, so no handler runs.
95
- - **Register everywhere your workflows run.** The terminal write can happen in any function invocation that processes the run's queue messages, so registration must run at startup in every instance of the app (which `instrumentation.ts` guarantees).
159
+ - **Register in each executor.** The terminal write can happen in any process that handles the run's queue messages. Use the [framework support table](#framework-support) to check whether app startup reaches that process.