workflow 5.3.0 → 5.5.0
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/observability.d.ts +1 -1
- package/dist/observability.d.ts.map +1 -1
- package/dist/observability.js +2 -2
- package/docs/ai/chat-session-modeling.mdx +1 -1
- package/docs/ai/resumable-streams.mdx +1 -1
- package/docs/api-reference/workflow/create-hook.mdx +3 -3
- package/docs/api-reference/workflow/create-webhook.mdx +1 -1
- package/docs/api-reference/workflow/fetch.mdx +1 -5
- package/docs/api-reference/workflow/get-step-metadata.mdx +19 -0
- package/docs/api-reference/workflow-ai/durable-agent.mdx +2 -1
- package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +4 -4
- package/docs/api-reference/workflow-api/get-hook-by-token.mdx +2 -2
- package/docs/api-reference/workflow-api/resume-hook.mdx +2 -2
- package/docs/api-reference/workflow-api/start.mdx +12 -8
- package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/index.mdx +1 -1
- package/docs/api-reference/workflow-errors/workflow-run-cancelled-error.mdx +1 -1
- package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +1 -1
- package/docs/api-reference/workflow-errors/workflow-start-error.mdx +5 -5
- package/docs/api-reference/workflow-next/with-workflow.mdx +57 -0
- package/docs/api-reference/workflow-observability/create-state-resolver.mdx +56 -0
- package/docs/api-reference/workflow-observability/index.mdx +5 -0
- package/docs/api-reference/workflow-observability/meta.json +1 -0
- package/docs/api-reference/workflow-runtime/world/storage.mdx +2 -3
- package/docs/changelog/attributes-mvp.mdx +1 -1
- package/docs/changelog/batched-event-writes.mdx +0 -2
- package/docs/changelog/eager-processing.mdx +3 -1
- package/docs/changelog/lazy-event-creation.md +1 -1
- package/docs/changelog/spec-9.mdx +268 -120
- package/docs/changelog/step-message-ownership.mdx +2 -7
- package/docs/configuration/build-and-diagnostics.mdx +2 -0
- package/docs/configuration/cli-and-web-ui.mdx +13 -2
- package/docs/configuration/framework-options.mdx +7 -0
- package/docs/configuration/runtime-tuning.mdx +26 -74
- package/docs/configuration/worlds.mdx +55 -23
- package/docs/cookbook/advanced/child-workflows.mdx +126 -186
- package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +1 -1
- package/docs/cookbook/common-patterns/idempotency.mdx +2 -2
- package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +1 -1
- package/docs/cookbook/common-patterns/workflow-composition.mdx +5 -5
- package/docs/cookbook/integrations/ai-sdk.mdx +2 -2
- package/docs/errors/corrupted-event-log.mdx +1 -1
- package/docs/errors/fetch-in-workflow.mdx +15 -35
- package/docs/errors/hook-force-claimed.mdx +1 -1
- package/docs/errors/runtime-decryption-failed.mdx +1 -1
- package/docs/foundations/errors-and-retries.mdx +3 -1
- package/docs/foundations/hooks.mdx +1 -1
- package/docs/foundations/idempotency.mdx +11 -11
- package/docs/foundations/serialization.mdx +80 -0
- package/docs/foundations/starting-workflows.mdx +3 -7
- package/docs/getting-started/next.mdx +2 -0
- package/docs/how-it-works/event-sourcing.mdx +2 -2
- package/docs/observability/index.mdx +2 -0
- package/docs/whats-new.mdx +4 -4
- package/docs/worlds/building-a-world.mdx +22 -7
- package/docs/worlds/local.mdx +11 -7
- package/docs/worlds/postgres.mdx +17 -24
- package/docs/worlds/upgrading-to-v5.mdx +3 -3
- package/docs/worlds/vercel.mdx +13 -12
- package/package.json +14 -14
|
@@ -8,8 +8,7 @@ description: Why inline step_started now records its owning queue message ID, wh
|
|
|
8
8
|
> Fixes [#2780](https://github.com/vercel/workflow/issues/2780) (duplicate
|
|
9
9
|
> inline step execution when a hook or wait wakes a run mid-step). This page
|
|
10
10
|
> is the design defense for the change: what it does, why each choice was
|
|
11
|
-
> made, and why the alternatives were rejected.
|
|
12
|
-
> `WORKFLOW_INLINE_OWNERSHIP=0`; lease tuning:
|
|
11
|
+
> made, and why the alternatives were rejected. Lease tuning:
|
|
13
12
|
> `WORKFLOW_INLINE_OWNERSHIP_LEASE_SECONDS` (see
|
|
14
13
|
> [Runtime tuning](/docs/configuration/runtime-tuning)).
|
|
15
14
|
|
|
@@ -301,9 +300,6 @@ heartbeat machinery rejected above.
|
|
|
301
300
|
ship into.
|
|
302
301
|
- **Version skew is a non-issue**: runs are pinned to their deployment, and old events
|
|
303
302
|
lack the field → unowned → current behavior. Nothing to migrate.
|
|
304
|
-
- **Kill switch**: `WORKFLOW_INLINE_OWNERSHIP=0` reverts dispatch to the unconditional
|
|
305
|
-
immediate requeue. Stamping continues (it is inert data), so the switch is purely a
|
|
306
|
-
dispatch-behavior toggle.
|
|
307
303
|
- **Degraded modes are all "today's behavior", never worse**: unstable message IDs (owner
|
|
308
304
|
check never matches → backstop-lease recovery), missing/unusable event timestamps
|
|
309
305
|
(lease remaining 0 → immediate enqueue), old backend (field dropped → unowned).
|
|
@@ -336,8 +332,7 @@ heartbeat machinery rejected above.
|
|
|
336
332
|
## How the design is protected by tests
|
|
337
333
|
|
|
338
334
|
- The **#2780 repro** (`workbench/vitest/test/inline-step-ownership.test.ts`): hook
|
|
339
|
-
resume mid-inline-step → side-effect marker fires exactly once.
|
|
340
|
-
with `WORKFLOW_INLINE_OWNERSHIP=0` the marker fires twice.
|
|
335
|
+
resume mid-inline-step → side-effect marker fires exactly once.
|
|
341
336
|
- **Unit**: the ownership state machine (stamp → wake sees owner → retrying clears → bare
|
|
342
337
|
start clears → re-stamp restores), lease math including the clock-skew clamp, and the
|
|
343
338
|
backstop key's epoch behavior, including a regression test walking the full
|
|
@@ -49,6 +49,8 @@ Accepted values:
|
|
|
49
49
|
- Framework option: `discoverWorkflowsInNodeModules` where supported
|
|
50
50
|
- Default: enabled
|
|
51
51
|
- Controls whether workflow discovery descends into `node_modules`. By default, dependencies that declare a `workflow`/`@workflow/*` dependency can ship `"use workflow"`/`"use step"` files that are discovered and compiled into your app's bundles.
|
|
52
|
+
- Dependencies without that declaration are not walked, but the file each import of them resolves to is still checked for serialization classes, and registered in the step bundle if it defines one. This is how AI SDK provider models (`@ai-sdk/openai`, `@ai-sdk/google`, and others) created inside a `"use workflow"` function deserialize in the steps they are passed to.
|
|
53
|
+
- Only that one file is checked: the class must be defined in the file your import resolves to. A class the file re-exports from another package or from a code-split chunk (`export { Model } from './chunk-….js'`) is not found this way. To register such a class, import the package that defines it directly, or reference it from a `"use step"` function so the step bundle loads it.
|
|
52
54
|
- Set `0` or `false` to opt out: imports from your application code that resolve into `node_modules` are not followed, so the build never reads, scans, or descends into dependency file graphs. This skips the cost of scanning `node_modules` and stops third-party workflow/step/serde code from being discovered. Useful when a dependency ships workflow code you don't want compiled into your app, or trips discovery with directive strings you don't intend to run.
|
|
53
55
|
- The SDK's own runtime serde classes (for example, `Run`) stay registered because they are reached through a seeded entry point, and imports *within* `node_modules` are still followed.
|
|
54
56
|
- Explicit framework config wins over this environment variable.
|
|
@@ -10,7 +10,7 @@ related:
|
|
|
10
10
|
|
|
11
11
|
The Workflow CLI uses flags first, then environment variables, then defaults or local inference.
|
|
12
12
|
|
|
13
|
-
Vercel project and auth settings can often be inferred from `.vercel/project.json` and your Vercel CLI login.
|
|
13
|
+
Vercel project and auth settings can often be inferred from `.vercel/project.json` and your Vercel CLI login. In a monorepo, the CLI uses the nearest `.vercel/project.json` before the repository's `.vercel/repo.json`.
|
|
14
14
|
|
|
15
15
|
Whichever way they are resolved, the CLI ends up building a Vercel World from an auth token plus a project ID, team ID, and environment — the same four values any external client needs. Set them explicitly when there is no interactive `vercel login` to infer from, or when writing your own script instead of using the CLI; see [Connecting from outside a deployment](/worlds/vercel#connecting-from-outside-a-deployment).
|
|
16
16
|
|
|
@@ -32,13 +32,15 @@ Whichever way they are resolved, the CLI ends up building a Vercel World from an
|
|
|
32
32
|
|
|
33
33
|
- Environment variable: `WORKFLOW_VERCEL_PROJECT`
|
|
34
34
|
- Default: inferred when possible
|
|
35
|
-
- Vercel project ID for `--backend vercel`.
|
|
35
|
+
- Vercel project ID or slug for `--backend vercel`.
|
|
36
|
+
- Takes precedence over the project in the `.vercel` link. When `--project` names a different project, pass `--team` too, or the CLI uses the linked team and logs a warning.
|
|
36
37
|
|
|
37
38
|
### `--team`
|
|
38
39
|
|
|
39
40
|
- Environment variable: `WORKFLOW_VERCEL_TEAM`
|
|
40
41
|
- Default: inferred when possible
|
|
41
42
|
- Vercel team ID for `--backend vercel`.
|
|
43
|
+
- Takes precedence over the team in the `.vercel` link.
|
|
42
44
|
|
|
43
45
|
### `WORKFLOW_VERCEL_PROJECT_NAME`
|
|
44
46
|
|
|
@@ -222,6 +224,14 @@ per flag.
|
|
|
222
224
|
- Local server port for health checks.
|
|
223
225
|
- The flag writes `WORKFLOW_LOCAL_BASE_URL`.
|
|
224
226
|
|
|
227
|
+
### `--base-path`
|
|
228
|
+
|
|
229
|
+
- Command: `workflow health`
|
|
230
|
+
- Environment variable: none
|
|
231
|
+
- Default: unset, so the check targets `/.well-known/workflow/v1/flow` at the server root
|
|
232
|
+
- Path the workflow routes are served under on the local server: Next.js' `basePath` followed by [`workflows.experimentalRoutePrefix`](/docs/api-reference/workflow-next/with-workflow#workflow-route-prefix). For example, `--base-path /v2/dashboard` checks `/v2/dashboard/.well-known/workflow/v1/flow`.
|
|
233
|
+
- Appended to the URL from `--port`, `WORKFLOW_LOCAL_BASE_URL` or `PORT`.
|
|
234
|
+
|
|
225
235
|
## Verbose logging and updates
|
|
226
236
|
|
|
227
237
|
### `--verbose` / `-v`
|
|
@@ -249,3 +259,4 @@ per flag.
|
|
|
249
259
|
- CLI flag: none
|
|
250
260
|
- Default: inferred
|
|
251
261
|
- Explicit path to the workflow manifest for the web UI.
|
|
262
|
+
- Inferred from `app/`, `src/app/` and `.well-known/` at the project root first, then from a manifest generated below a [route prefix](/docs/api-reference/workflow-next/with-workflow#workflow-route-prefix), such as `app/dashboard/.well-known/workflow/v1/manifest.json`. Set it when more than one prefixed manifest exists.
|
|
@@ -28,6 +28,13 @@ Framework options are read at build or dev-server startup. Use them for settings
|
|
|
28
28
|
- Controls source maps for generated workflow bundles.
|
|
29
29
|
- Explicit config wins over `WORKFLOW_SOURCEMAP`.
|
|
30
30
|
|
|
31
|
+
### `workflows.experimentalRoutePrefix`
|
|
32
|
+
|
|
33
|
+
- Environment override: none
|
|
34
|
+
- Default: none, so the routes are generated at the app root
|
|
35
|
+
- Experimental. Emits the generated workflow routes below a route segment the app owns, such as `/dashboard/.well-known/workflow/v1/flow`, for apps that cannot own the origin's root paths.
|
|
36
|
+
- See [`withWorkflow`](/docs/api-reference/workflow-next/with-workflow#workflow-route-prefix) for the generated paths and the Turborepo caching caveat.
|
|
37
|
+
|
|
31
38
|
```typescript title="next.config.ts" lineNumbers
|
|
32
39
|
import { withWorkflow } from "workflow/next";
|
|
33
40
|
|
|
@@ -38,12 +38,12 @@ The runtime reads these variables where workflows execute. Set them on the deplo
|
|
|
38
38
|
- Runs longer than roughly `WORKFLOW_RETURN_VALUE_MAX_LONG_POLLS` x `WORKFLOW_RETURN_VALUE_WAIT_MS` therefore spend most of their life interval polling, which costs more requests than continuing to wait would. Raise it if you routinely await long runs.
|
|
39
39
|
- Read by the process awaiting `Run.returnValue`, like the interval above.
|
|
40
40
|
|
|
41
|
-
### `
|
|
41
|
+
### `WORKFLOW_CHILD_RUN_COMPLETION_HOOK`
|
|
42
42
|
|
|
43
43
|
- Default: enabled
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
- Read by the
|
|
44
|
+
- Inside a workflow, awaiting `returnValue` of a run that workflow started suspends the parent on a system hook the child resumes when it finishes, instead of polling. See [Child Workflows](/cookbook/advanced/child-workflows#how-the-parent-waits).
|
|
45
|
+
- Set to `0` or `false` to stop `start()` from marking new child runs for the hook, so their parents poll `returnValue` inside a step on the variables above.
|
|
46
|
+
- Read by the deployment calling `start()` from a workflow. A child already marked keeps resuming its parent, so a parent waiting on it is never stranded.
|
|
47
47
|
|
|
48
48
|
## Replay and queue delivery
|
|
49
49
|
|
|
@@ -68,6 +68,19 @@ For example, a workflow can run a 10-minute inline step even with `WORKFLOW_REPL
|
|
|
68
68
|
- Delivery attempts before a run or step is failed gracefully.
|
|
69
69
|
- Can only be lowered. Workflow calibrates the default to record failure before the queue expires the message.
|
|
70
70
|
|
|
71
|
+
### `WORKFLOW_QUEUE_AUTH`
|
|
72
|
+
|
|
73
|
+
- Default: `on`
|
|
74
|
+
- Applies to the [Local World](/worlds/local), and to any World that declares `queueAuthMode: 'loopback'`. A World that declares nothing is not checked; the runtime logs a warning when its flow route starts (once, then at most once a minute when routes restart). With `on`, the Workflow SDK's flow route (`POST /.well-known/workflow/v1/flow`) accepts only deliveries sent by the app's own processes. A queue consumer's own route (built with `world.createQueueHandler()` and registered with `registerRoute()`) is not checked; it must authenticate deliveries itself, or sit behind the network edge.
|
|
75
|
+
- Every delivery the Local World sends carries the app's queue key. The route refuses a request that does not carry the key with a `401`, before it reads the body, and does not touch any run. A request from outside the app therefore cannot start a run, fail a running one, re-trigger a step, or replay a delivery.
|
|
76
|
+
- The key is a random value in the file `queue-auth-key` in the Local World's data directory, readable only by its owner (Windows does not enforce that the same way). The app writes a new key each time it starts, before it sends any delivery, and the data directory gets a `.gitignore` that keeps the key out of git. See [the Local World's data directory](/worlds/local#data-directory-layout).
|
|
77
|
+
- The usual setups need nothing: the app's own queue, the CLI, the web UI, a script calling `start()` or `resumeHook()`, and several app processes all use the same data directory, so they send a key the app accepts. Point the CLI and the web UI at the app's data directory (`WORKFLOW_LOCAL_DATA_DIR`). Set `off` on the app only when a delivery comes from a process that cannot read that directory.
|
|
78
|
+
- `off` accepts unauthenticated deliveries. Use it only for local development or on a trusted network. The runtime logs a warning when a route starts with `off`.
|
|
79
|
+
- `off` is refused while [dynamic workflows](/docs/advanced/dynamic-workflows) are enabled (`WORKFLOW_EXPERIMENTAL_DYNAMIC_WORKFLOWS`). Both variables are read on every delivery, so the check comes back on as soon as dynamic workflows are enabled.
|
|
80
|
+
- The `401` is marked as the runtime's own refusal (an `x-workflow-auth-refused: 1` header). The Local World's queue then reads the key file again: if another process wrote a new key, it retries at once with that key. Otherwise it retries a few times with its short backoff, then logs one line and gives the message up. A refused delivery reaches no handler and touches no run, so retrying it is safe and it does not count as an attempt. A given-up message's run is left as it was. A `401` without the marker, for example from a proxy, gets the queue's normal retries.
|
|
81
|
+
- Each refusal increments the OpenTelemetry counter `workflow.queue.delivery.refused` (when a meter provider is registered). Its attributes are `workflow.world`, `http.route`, and `workflow.queue.refusal_reason` (`no-key` or `wrong-key`). A refusal right after the app, the CLI or a script starts is expected: it wrote a new key, and the sender reloads it and retries on its own. Alert on refusals that persist, which mean forged requests or a sender that cannot get the app's key. The refusal log is rate-limited to one line a minute per process; the counter counts every refusal.
|
|
82
|
+
- Any value other than `off` leaves the check on. Worlds that declare `queueAuthMode: 'skip'` are not checked and are not affected. The [Vercel World](/worlds/vercel) delivers to a route only Vercel Queues can trigger (see its [security section](/worlds/vercel#security)). The [Postgres World](/worlds/postgres) relies on its database credentials to control who can enqueue, and its flow route accepts any well-formed request, so protect that route at the network edge, as its [security section](/worlds/postgres#protect-the-queue-route) describes.
|
|
83
|
+
|
|
71
84
|
### `WORKFLOW_MAX_EVENTS`
|
|
72
85
|
|
|
73
86
|
- Default: `25000`
|
|
@@ -107,25 +120,6 @@ For example, a workflow can run a 10-minute inline step even with `WORKFLOW_REPL
|
|
|
107
120
|
- A World that does refuse should only ever do so on evidence, and accept the write in every other case. A rejection then always means the position was stale, while the absence of one proves nothing about currency.
|
|
108
121
|
- Two runtime behaviors follow from the properties above rather than from any fence. The per-step event-log delta optimization (consuming the delta returned by a step's terminal write instead of issuing an extra `events.list` per step) stays active while the run has an open hook. A `hook_received` event missed by the delta window is observed one iteration later, and the next write brings it back. While a hook is open, inline steps take the await-then-run path even when optimistic inline start is enabled. Several invocations race for one step's claim there, and awaiting it means the body runs only for the writer that won.
|
|
109
122
|
|
|
110
|
-
### `WORKFLOW_SLOT_GAP_CHECK`
|
|
111
|
-
|
|
112
|
-
- Default: enabled
|
|
113
|
-
- A replay checks that the [event log](/docs/how-it-works/event-sourcing#event-ids) it loaded is dense before it runs, and fails the run with [`CORRUPTED_EVENT_LOG`](/docs/errors/corrupted-event-log) when a position below the log's highest holds no event. A log missing only its first position, meaning a run whose `run_created` is still being written, is left alone.
|
|
114
|
-
- A position can be briefly empty while the write that occupies it is still committing, so the check re-reads the log a few times before it decides, and the replay continues from whichever log it settled on.
|
|
115
|
-
- The check trades one failure for another. Most holes stand for an event that never happened, and replaying past those is correct. A hole standing for an event that did happen looks identical, and replaying past that one produces a run whose result is silently wrong. Failing is the recoverable side of that trade.
|
|
116
|
-
- Set `0` to replay across holes instead.
|
|
117
|
-
|
|
118
|
-
### `WORKFLOW_SEALED_LOG`
|
|
119
|
-
|
|
120
|
-
- Default: enabled
|
|
121
|
-
- New runs are created at the sealed-log spec version, in which the World's backend assigns each event its position *before* the write commits rather than letting concurrent writers race for one. Concurrent writes then never contend for a position, which is what makes a wide fan-out cheap.
|
|
122
|
-
- The price of assigning positions in advance is that a writer which claims one and then dies leaves a position no writer will ever fill. The backend closes such a position by writing a `noop` event into it once it can prove the position was abandoned, so a reader still sees the dense log it needs. Replay steps over a `noop` without delivering it to the workflow or advancing the deterministic clock. Its timestamp belongs to whichever reader sealed it, not to the run.
|
|
123
|
-
- Set `0` to put a deployment back on the previous scheme, where each position is allocated by the write that occupies it. Use this as the kill switch if position assignment turns out to be at fault for event-log problems.
|
|
124
|
-
- Setting `0` also stamps new runs below spec version 8, so another run can't take their hook tokens over with [`experimental_force`](/docs/api-reference/workflow/create-hook#take-over-a-token-another-run-holds). A forced hook in another run gets `HookConflictError` instead. Runs created with `0` can still take tokens over from others.
|
|
125
|
-
- Existing runs are unaffected either way. A run's spec version is stamped once, at creation, and read from the run for the rest of its life, so flipping this changes only what *new* runs get, and a run in flight keeps the scheme it started on. Every build reads sealed logs regardless of the setting.
|
|
126
|
-
- A run created at the sealed-log version can only be replayed by a reader that knows to skip `noop` events. That includes every runtime on this release train, but a runtime that pins its own accepted spec range separately, such as the Python runtime, has to catch up before it can read these runs. Switch this off in an environment where it has not.
|
|
127
|
-
- Only the Vercel World seals. The Local and Postgres Worlds allocate each position at the commit that occupies it, so they cannot leave a hole and never write a `noop`; the setting still moves the version they stamp, so the fleet stays on one spec.
|
|
128
|
-
|
|
129
123
|
### `WORKFLOW_PRECONDITION_MAX_INPROCESS_RESTARTS`
|
|
130
124
|
|
|
131
125
|
- Default: `3`
|
|
@@ -144,16 +138,6 @@ For example, a workflow can run a 10-minute inline step even with `WORKFLOW_REPL
|
|
|
144
138
|
- Delay before a re-invocation caused by a rejected event creation.
|
|
145
139
|
- Unlike an in-process restart, which re-reads immediately, a re-invocation only happens after the in-process budget fails to catch up. The delay gives the other writers time to quiesce.
|
|
146
140
|
|
|
147
|
-
### `WORKFLOW_LOG_ORDER_DRAWS`
|
|
148
|
-
|
|
149
|
-
- Default: enabled
|
|
150
|
-
- Experimental. Pins correlation-ID draw order to event-log order. A branch-deciding delivery (a step result, hook payload, or wait completion) resolves to the workflow only after every earlier-in-log delivery's continuation has fully quiesced, and never ahead of a lower-slot delivery that is committed to happening.
|
|
151
|
-
- Without it, a delivery that resolves while an earlier delivery's continuation is still a few microtask hops from its next step/hook/wait call can overtake it on the run's shared correlation-ID sequence. Draw order, and therefore correlation IDs, then depends on how much of the event log a replay had loaded. Two concurrent replays holding different-length prefixes can bind one ID to two different entities, failing the run with `CORRUPTED_EVENT_LOG`.
|
|
152
|
-
- Costs one event-loop turn (roughly 15 to 20 microseconds via `setImmediate`) per branch-deciding delivery during replay, and more when continuations genuinely overlap. Measurements on a 100-step sequential replay show about 2 ms added end to end.
|
|
153
|
-
- Only applies to the default Node.js VM engine. `WORKFLOW_VM=quickjs` has its own event feed and correlation-ID sequence and is unaffected by this setting.
|
|
154
|
-
- Correlation IDs of runs created before the setting changed are not affected on platforms where a run keeps replaying on the deployment it started on. Elsewhere, only change it while no runs are in flight.
|
|
155
|
-
- Set `0` to opt back into arrival-order delivery resolution. Only the literal value `0` opts out; `false` or `off` leave it enabled.
|
|
156
|
-
|
|
157
141
|
## Inline execution
|
|
158
142
|
|
|
159
143
|
### `WORKFLOW_V2_TIMEOUT_MS`
|
|
@@ -170,18 +154,6 @@ For example, a workflow can run a 10-minute inline step even with `WORKFLOW_REPL
|
|
|
170
154
|
- Number of newly-created steps one invocation runs inline in parallel before queueing the rest.
|
|
171
155
|
- Steps started beside an awaited hook registration (`hook.getConflict()`) count against the same cap. They are held for the pass that observes the registration and then run inline on it, so the registration still precedes them; only the steps past the cap are queued.
|
|
172
156
|
|
|
173
|
-
### `WORKFLOW_INLINE_EARLY_ADVANCE`
|
|
174
|
-
|
|
175
|
-
- Default: enabled
|
|
176
|
-
- Spec 8 runs on the Node.js VM engine only (not QuickJS, and not spec 9 runs). When one inline step of a parallel batch completes or fails while its siblings are still running, the invocation replays the workflow right away instead of waiting for the slowest sibling. A branch of a `Promise.all` can then start its next step without waiting for the other branches.
|
|
177
|
-
- Steps still running stay owned by the invocation that started them. They count against `WORKFLOW_MAX_INLINE_STEPS`, so fewer new steps run inline while they run. A branch that fans out while its siblings still run queues the steps past the remaining slots as background steps.
|
|
178
|
-
- When the workflow returns or throws while one of its inline steps is still running (for example a `Promise.race` loser), the run completes or fails right away. That step gets only its current attempt: the invocation lets its body finish, and the bundled Worlds record its `step_completed`, `step_failed` or `step_retrying` after the run's terminal event, but a retry is never run, so a step whose attempt fails retryably stays pending. This matches what happens when a `sleep()` or hook wins a race. `run_completed` or `run_failed` is therefore not always the last event of a run. With this setting off, the run waits for the loser and its retries. The `workflow.inline.running_at_terminal` and `workflow.inline.discarded_outcomes` span attributes, and an info log, report these steps.
|
|
179
|
-
- A step that retries, is throttled, or leaves stream writes unflushed waits for its whole batch, as with this setting off.
|
|
180
|
-
- Branches whose steps were queued because the batch exceeded `WORKFLOW_MAX_INLINE_STEPS` still advance only when the last pending step of the batch completes.
|
|
181
|
-
- When the invocation hands the run off (its replay budget or inline window is spent), it waits for every inline step still running first, so branches advance in lockstep at that point, as with this setting off. An info log marks the hand-off.
|
|
182
|
-
- `workflow.inline.early_advances` counts early replays and `workflow.inline.slots_held_back` counts steps queued because running steps held the inline slots.
|
|
183
|
-
- Set `0` or `false` to wait for every inline step of a batch before replaying.
|
|
184
|
-
|
|
185
157
|
### `WORKFLOW_TURBO`
|
|
186
158
|
|
|
187
159
|
- Default: enabled
|
|
@@ -204,12 +176,6 @@ For example, a workflow can run a 10-minute inline step even with `WORKFLOW_REPL
|
|
|
204
176
|
- Step inputs made of plain data (objects, arrays, primitives) and standard built-ins (`Map`, `Set`, `Date`, `RegExp`, typed arrays, `ArrayBuffer`, `URL`, `Headers`) keep the VM retained. Patching or polyfilling built-in prototypes doesn't change that because serialization never calls them. A boundary falls back to a full replay only when serializing its arguments runs code the workflow controls, such as a getter, a proxy, or a custom class serializer, or computes an `Error`'s stack trace.
|
|
205
177
|
- Set `0` or `false` to replay the Node.js workflow from scratch in a fresh VM on every iteration.
|
|
206
178
|
|
|
207
|
-
### `WORKFLOW_INLINE_OWNERSHIP`
|
|
208
|
-
|
|
209
|
-
- Default: enabled
|
|
210
|
-
- Records which queue message owns each inline step execution, so a wake (hook resume, elapsed wait) that replays the run mid-step schedules a delayed backstop instead of immediately redispatching and reexecuting the step. See [Inline step message ownership](/docs/changelog/step-message-ownership).
|
|
211
|
-
- Set `0` or `false` to revert to the previous unconditional immediate re-dispatch.
|
|
212
|
-
|
|
213
179
|
### `WORKFLOW_INLINE_OWNERSHIP_LEASE_SECONDS`
|
|
214
180
|
|
|
215
181
|
- Default: `860`
|
|
@@ -308,12 +274,7 @@ What a snapshot contains, and how it is protected:
|
|
|
308
274
|
|
|
309
275
|
## Transport
|
|
310
276
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
- Default: enabled
|
|
314
|
-
- On the Vercel World, lets concurrent event-log requests share one HTTP/2 connection instead of one connection per in-flight request.
|
|
315
|
-
- Set `0` to take the event-log requests off HTTP/2 entirely, back to one request per HTTP/1.1 connection. Use this as the kill switch if HTTP/2 turns out to be at fault for event delivery problems.
|
|
316
|
-
- Has no effect when `WORKFLOW_NODE_HTTP` is enabled, which takes the whole HTTP/2 path away.
|
|
277
|
+
The Vercel World's own transport settings (HTTP/2 multiplexing and the queue client's deadline and connection pool) are listed under [Vercel World](/docs/configuration/worlds#vercel-world).
|
|
317
278
|
|
|
318
279
|
### `WORKFLOW_NODE_HTTP`
|
|
319
280
|
|
|
@@ -332,21 +293,6 @@ Connection pooling, keep-alive, and the request, header, and body deadlines are
|
|
|
332
293
|
|
|
333
294
|
A `dispatcher` passed to `createVercelWorld()` still wins over this variable. The variable chooses which transport the World builds when you have not supplied one.
|
|
334
295
|
|
|
335
|
-
### `WORKFLOW_VERCEL_QUEUE_TIMEOUT_MS`
|
|
336
|
-
|
|
337
|
-
- Default: `30000`
|
|
338
|
-
- Total deadline for one request the Vercel World's queue client makes, measured from the moment it is handed to the transport, so it also covers time the request spends waiting for a free connection.
|
|
339
|
-
- Clamped to `[5000, 120000]`.
|
|
340
|
-
- This is the only request path the World cannot bound with `WORKFLOW_REQUEST_TIMEOUT_MS`, because the queue client makes its own calls and accepts no override for them. Without a deadline here, a queue acknowledgement that never completes holds the invocation until the platform kills it, and a killed invocation never acknowledges, so the message is redelivered.
|
|
341
|
-
- Keep it below the queue's visibility-renewal interval (60 seconds) so a failed call has room to surface and be retried before the message lease lapses.
|
|
342
|
-
|
|
343
|
-
### `WORKFLOW_VERCEL_QUEUE_CONNECTIONS`
|
|
344
|
-
|
|
345
|
-
- Default: `64`
|
|
346
|
-
- Connections the Vercel World's queue client may open to the queue service.
|
|
347
|
-
- Clamped to `[1, 1024]`.
|
|
348
|
-
- Sized much higher than the World's other connection pools on purpose. The queue client makes roughly two small requests per invocation, so its concurrency tracks how many invocations a compute instance is serving at once rather than any per-request fan-out. Lower it only if you have a reason to cap sockets; too low turns invocation concurrency into the limit on how fast messages can be acknowledged.
|
|
349
|
-
|
|
350
296
|
## Queue namespace
|
|
351
297
|
|
|
352
298
|
### `WORKFLOW_QUEUE_NAMESPACE`
|
|
@@ -439,8 +385,9 @@ Everything above describes spec 8 runs, the default. The experimental spec 9 run
|
|
|
439
385
|
|
|
440
386
|
### `WORKFLOW_SPEC_VERSION`
|
|
441
387
|
|
|
442
|
-
- Default: unset. New runs use spec version 8
|
|
388
|
+
- Default: unset. New runs use spec version 8.
|
|
443
389
|
- `9` creates spec 9 runs on a World that declares the in-band fence (the Vercel, Local and Postgres Worlds do). `6` to `8` select that version. A run keeps the version it was created with.
|
|
390
|
+
- `6` creates new runs on the scheme from before the [sealed log](/docs/how-it-works/event-sourcing), where each event position is allocated by the write that occupies it. Use it in an environment shared with a runtime that cannot read sealed logs yet, such as one that pins its own accepted spec range (the Python runtime). Runs below `8` cannot have their hook tokens taken over with [`experimental_force`](/docs/api-reference/workflow/create-hook#take-over-a-token-another-run-holds): a forced hook in another run gets `HookConflictError` instead.
|
|
444
391
|
- Upgrade every deployment and process that shares the World before setting it, and do not roll back below this release once spec 9 runs exist. See [Opting in](/docs/changelog/spec-9#opting-in).
|
|
445
392
|
|
|
446
393
|
### `WORKFLOW_ORCHESTRATOR_POLL_INTERVAL_MS`
|
|
@@ -456,7 +403,12 @@ Everything above describes spec 8 runs, the default. The experimental spec 9 run
|
|
|
456
403
|
### `WORKFLOW_ORCHESTRATOR_LINGER_MS`
|
|
457
404
|
|
|
458
405
|
- Default: `30000`
|
|
459
|
-
- How long an orchestrator with nothing left to run stays live on the event feed while the run waits on
|
|
406
|
+
- How long an orchestrator with nothing left to run stays live on the event feed while the run waits on a background step. `0` turns it off, for hooks too.
|
|
407
|
+
|
|
408
|
+
### `WORKFLOW_ORCHESTRATOR_HOOK_LINGER_MS`
|
|
409
|
+
|
|
410
|
+
- Default: `5000`, and never more than [`WORKFLOW_ORCHESTRATOR_LINGER_MS`](#workflow_orchestrator_linger_ms)
|
|
411
|
+
- How long an orchestrator with nothing left to run stays live on the event feed while the run waits only on open hooks. Any hook that is created and not disposed counts, however rarely it is resumed. `0` turns it off.
|
|
460
412
|
|
|
461
413
|
### `WORKFLOW_ORCHESTRATOR_READ_TIMEOUT_MS`
|
|
462
414
|
|
|
@@ -62,6 +62,7 @@ The Local World is the default outside Vercel and is intended for development.
|
|
|
62
62
|
- Environment variable: `WORKFLOW_LOCAL_DATA_DIR`
|
|
63
63
|
- Default: `.workflow-data`
|
|
64
64
|
- Directory where runs, steps, events, hooks, streams, and the local manifest are written.
|
|
65
|
+
- Also holds the app's queue key (`queue-auth-key`), which the CLI and web UI read to send deliveries, so point them at the same directory. See [`WORKFLOW_QUEUE_AUTH`](/worlds/local#workflow_queue_auth).
|
|
65
66
|
|
|
66
67
|
### `baseUrl`
|
|
67
68
|
|
|
@@ -161,7 +162,7 @@ The Postgres World is a self-hosted durable backend for long-running server proc
|
|
|
161
162
|
- Environment variable: `WORKFLOW_POSTGRES_WORKER_CONCURRENCY`
|
|
162
163
|
- Default: `50`
|
|
163
164
|
- Number of concurrent workers polling for jobs.
|
|
164
|
-
- Also bounds concurrent parent
|
|
165
|
+
- Also bounds concurrent `returnValue` polls that run inside steps. A parent workflow awaiting a child it started suspends on a system hook instead and holds no worker (see [Child Workflows](/cookbook/advanced/child-workflows#how-the-parent-waits)).
|
|
165
166
|
|
|
166
167
|
### `pollInterval`
|
|
167
168
|
|
|
@@ -180,12 +181,11 @@ The Postgres World is a self-hosted durable backend for long-running server proc
|
|
|
180
181
|
### `jobLockStaleSeconds`
|
|
181
182
|
|
|
182
183
|
- Environment variable: `WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS`
|
|
183
|
-
- Default:
|
|
184
|
-
- Seconds a running delivery's job lock may go unrenewed before another process releases
|
|
184
|
+
- Default: unset. Every delivery renews its job lock, and a job in a spec 9 run's named queue whose process died is redelivered after 300 seconds unrenewed, if its holder registered as renewing. Other jobs keep Graphile Worker's fixed 4 hour reset.
|
|
185
|
+
- Seconds a running delivery's job lock may go unrenewed before another process releases any of this World's jobs for redelivery. Setting it extends the release from spec 9 named queues to every job, whoever holds it.
|
|
185
186
|
- `30` is a good value when more than one process shares the database. Use the same value on every process, and keep it well above the longest a process can block its event loop.
|
|
186
|
-
- `0` leaves recovery to Graphile Worker's fixed 4 hour reset and to restarts.
|
|
187
|
-
-
|
|
188
|
-
- To turn it on, set the same value on every process that shares the database once all of them run a version that includes this option. See [Postgres World: `WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS`](/worlds/postgres#workflow_postgres_job_lock_stale_seconds).
|
|
187
|
+
- `0` turns renewal and release off, and leaves recovery to Graphile Worker's fixed 4 hour reset and to restarts.
|
|
188
|
+
- Set it only once every process that shares the database runs a version that includes this option. A process on an earlier version neither renews its locks nor fences its acknowledgement on the lock holder, so while it shares the database with a process that has this set, its deliveries that run longer than the window are redelivered, and finishing one can delete the redelivered job. The default is safe for this: it never releases the job of a holder that did not register as renewing. See [Postgres World: `WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS`](/worlds/postgres#workflow_postgres_job_lock_stale_seconds).
|
|
189
189
|
|
|
190
190
|
### `maxPoolSize`
|
|
191
191
|
|
|
@@ -193,6 +193,25 @@ The Postgres World is a self-hosted durable backend for long-running server proc
|
|
|
193
193
|
- Default: `pg` default
|
|
194
194
|
- Maximum size of the internal `pg.Pool` when the World creates the pool.
|
|
195
195
|
|
|
196
|
+
### `enableInvoke`
|
|
197
|
+
|
|
198
|
+
- Environment variable: `WORKFLOW_POSTGRES_INVOKE` (`1` enables)
|
|
199
|
+
- Default: `false`
|
|
200
|
+
- Experimental. Delivers hook resumes to the run's executor instead of writing the hook event and enqueueing a wake-up. Apply the migrations and upgrade producers and workers together before enabling it. See [experimental invocation delivery](/worlds/postgres#experimental-invocation-delivery).
|
|
201
|
+
|
|
202
|
+
### `WORKFLOW_POSTGRES_HEADERS_TIMEOUT_MS`
|
|
203
|
+
|
|
204
|
+
- Factory option: none
|
|
205
|
+
- Default: `0` (no deadline)
|
|
206
|
+
- Maximum time a queue delivery waits for the workflow handler to begin responding before it is failed and redelivered.
|
|
207
|
+
- A delivery runs the workflow inline, so a deadline shorter than your longest inline step redelivers a healthy delivery and runs its steps twice. See [`WORKFLOW_POSTGRES_HEADERS_TIMEOUT_MS`](/worlds/postgres#workflow_postgres_headers_timeout_ms).
|
|
208
|
+
|
|
209
|
+
### `WORKFLOW_POSTGRES_BODY_TIMEOUT_MS`
|
|
210
|
+
|
|
211
|
+
- Factory option: none
|
|
212
|
+
- Default: `0` (no deadline)
|
|
213
|
+
- Maximum gap between response body chunks from the workflow handler before the delivery is failed and redelivered. The same caution as `WORKFLOW_POSTGRES_HEADERS_TIMEOUT_MS` applies.
|
|
214
|
+
|
|
196
215
|
### `WORKFLOW_POSTGRES_HOOK_RETENTION_LIMIT_DAYS`
|
|
197
216
|
|
|
198
217
|
- Factory option: none
|
|
@@ -278,7 +297,7 @@ Platform-provided values such as `VERCEL_DEPLOYMENT_ID`, `VERCEL_PROJECT_ID`, an
|
|
|
278
297
|
- Factory option: none
|
|
279
298
|
- CLI flag: none
|
|
280
299
|
- Default: unset
|
|
281
|
-
- Direct
|
|
300
|
+
- Direct Vercel World backend URL override for testing or custom infrastructure. Normal deployments do not need it.
|
|
282
301
|
|
|
283
302
|
### `VERCEL_QUEUE_MAX_DELAY_SECONDS`
|
|
284
303
|
|
|
@@ -296,16 +315,9 @@ Platform-provided values such as `VERCEL_DEPLOYMENT_ID`, `VERCEL_PROJECT_ID`, an
|
|
|
296
315
|
- CLI flag: none
|
|
297
316
|
- Default: `60000`
|
|
298
317
|
- Clamp: `10000` to `120000` (values outside are clamped, with a warning)
|
|
299
|
-
- Per-request timeout for Vercel World HTTP calls to
|
|
318
|
+
- Per-request timeout for Vercel World HTTP calls to its backend.
|
|
300
319
|
- At the `10000` floor the run-status long poll disables itself, because its budget is this value minus 10s of headroom.
|
|
301
320
|
|
|
302
|
-
### `WORKFLOW_MAX_CHUNKS_PER_REQUEST`
|
|
303
|
-
|
|
304
|
-
- Factory option: none
|
|
305
|
-
- CLI flag: none
|
|
306
|
-
- Default: `1000`
|
|
307
|
-
- Maximum stream chunks written in one Vercel World request. Larger batches are split.
|
|
308
|
-
|
|
309
321
|
### `WORKFLOW_STREAMS_TRANSPORT`
|
|
310
322
|
|
|
311
323
|
- Factory option: none
|
|
@@ -325,14 +337,6 @@ Platform-provided values such as `VERCEL_DEPLOYMENT_ID`, `VERCEL_PROJECT_ID`, an
|
|
|
325
337
|
- Default: disabled
|
|
326
338
|
- Set `1` to turn off the World's metadata-only `analytics` read namespace, forcing `workflow inspect` and web UI list views onto strongly consistent primary storage. Intended for tests and tooling that read entities immediately after writing them.
|
|
327
339
|
|
|
328
|
-
### `WORKFLOW_BATCH_TRANSITIONS`
|
|
329
|
-
|
|
330
|
-
- Surface: environment variable
|
|
331
|
-
- Default: on
|
|
332
|
-
- Set to `0` (or `false`) to **disable** batched event writes, the escape hatch that restores the exact prior one-write-per-event path.
|
|
333
|
-
|
|
334
|
-
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. 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.
|
|
335
|
-
|
|
336
340
|
### `WORKFLOW_EVENTS_TRANSPORT`
|
|
337
341
|
|
|
338
342
|
- Factory option: none
|
|
@@ -359,3 +363,31 @@ When enabled (the default), a suspension's eager `step_created` and `wait_create
|
|
|
359
363
|
- Largest WebSocket message the Vercel World sends, header included, for both the events and stream-write transports. The ceiling is the 16 MiB WebSocket message limit.
|
|
360
364
|
- Events: a larger frame is sent as several messages and rebuilt on the other side.
|
|
361
365
|
- Stream writes: a larger write group is split into several ordered write requests; a single chunk too large for one message is written over HTTP, as are the rest of that writer's writes.
|
|
366
|
+
|
|
367
|
+
### `WORKFLOW_H2_MULTIPLEX`
|
|
368
|
+
|
|
369
|
+
- Factory option: none
|
|
370
|
+
- CLI flag: none
|
|
371
|
+
- Default: enabled
|
|
372
|
+
- On the Vercel World, lets concurrent event-log requests share one HTTP/2 connection instead of one connection per in-flight request.
|
|
373
|
+
- Set `0` to take the event-log requests off HTTP/2 entirely, back to one request per HTTP/1.1 connection. Use this as the kill switch if HTTP/2 turns out to be at fault for event delivery problems.
|
|
374
|
+
- Has no effect when [`WORKFLOW_NODE_HTTP`](/docs/configuration/runtime-tuning#workflow_node_http) is enabled, which takes the whole HTTP/2 path away.
|
|
375
|
+
|
|
376
|
+
### `WORKFLOW_VERCEL_QUEUE_TIMEOUT_MS`
|
|
377
|
+
|
|
378
|
+
- Factory option: none
|
|
379
|
+
- CLI flag: none
|
|
380
|
+
- Default: `30000`
|
|
381
|
+
- Total deadline for one request the Vercel World's queue client makes, measured from the moment it is handed to the transport, so it also covers time the request spends waiting for a free connection.
|
|
382
|
+
- Clamped to `[5000, 120000]`.
|
|
383
|
+
- This is the only request path the World cannot bound with `WORKFLOW_REQUEST_TIMEOUT_MS`, because the queue client makes its own calls and accepts no override for them. Without a deadline here, a queue acknowledgement that never completes holds the invocation until the platform kills it, and a killed invocation never acknowledges, so the message is redelivered.
|
|
384
|
+
- Keep it below the queue's visibility-renewal interval (60 seconds) so a failed call has room to surface and be retried before the message lease lapses.
|
|
385
|
+
|
|
386
|
+
### `WORKFLOW_VERCEL_QUEUE_CONNECTIONS`
|
|
387
|
+
|
|
388
|
+
- Factory option: none
|
|
389
|
+
- CLI flag: none
|
|
390
|
+
- Default: `64`
|
|
391
|
+
- Connections the Vercel World's queue client may open to the queue service.
|
|
392
|
+
- Clamped to `[1, 1024]`.
|
|
393
|
+
- Sized much higher than the World's other connection pools on purpose. The queue client makes roughly two small requests per invocation, so its concurrency tracks how many invocations a compute instance is serving at once rather than any per-request fan-out. Lower it only if you have a reason to cap sockets; too low turns invocation concurrency into the limit on how fast messages can be acknowledged.
|