workflow 5.2.1 → 5.2.2

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.
@@ -64,7 +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
+ * `compressArguments: false` stores the run's arguments uncompressed. By default they are compressed when the target run can decode them. Arguments of 256 KiB or more are compressed off the caller's event loop, so starting a run with a large input doesn't stall other requests the process is serving. The attempt still 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).
68
68
 
69
69
  <Callout type="info">
70
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).
@@ -62,7 +62,7 @@ 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 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.
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; 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
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
 
@@ -89,15 +89,6 @@ For example, a workflow can run a 10-minute inline step even with `WORKFLOW_REPL
89
89
  - Only applies to Worlds with atomic, immutable deployments (the Vercel World). A run whose pinned deployment cannot be reached at all fails immediately regardless of this value.
90
90
  - Transient or unknown queue publishing failures use normal queue redelivery and do not consume this budget.
91
91
 
92
- ### `WORKFLOW_RESILIENT_STEP_DISPATCH`
93
-
94
- - Default: disabled
95
- - When a suspension hands newly created steps to the queue, the runtime publishes each step's execution message in parallel with its `step_created` event write instead of sequencing them, cutting a round trip per dispatched step. The message also carries the serialized step input (`stepInput`), so a transient `step_created` write failure (429 / 5xx / transport) still executes the step. The queue consumer idempotently re-ensures the event before running it, converging with the producer's write on the step's correlation ID. This mirrors resilient start (`runInput`) and the legacy lazy hook resume's `hookInput` (which current producers no longer send; see [durable hook resume](/docs/changelog/lazy-hook-resume)).
96
- - It is off by default because the publish races the create's verdict, and a create can come back refused: as a duplicate this replay should stop pursuing, or as a [stale write](#stale-reads-and-why-nothing-has-to-be-rejected) on a World that refuses rather than reports. Either way the message carrying the payload is already out, so the consumer can materialize a step whose create was refused, and nothing orders the verdict before the consumer's redelivery re-ensure. The sequential path is the only one that gives the message a happens-after edge over it.
97
- - Even when enabled, the runtime falls back to the sequential create-then-publish dispatch when the step input is too large to inline on the queue message, or when the run's queue transport cannot carry binary payloads (pre-CBOR spec versions).
98
- - Producer-side recoveries are reported on the suspension span as `workflow.step.resilient_dispatch_recovered`; a consumer that materialized the event reports `workflow.step.resilient_dispatch_materialized`.
99
- - Set `1` to enable it.
100
-
101
92
  ### `WORKFLOW_OPEN_WAIT_CLOCK_SKEW_MS`
102
93
 
103
94
  - Default: `30000` (30 seconds)
@@ -279,6 +270,7 @@ What a snapshot contains, and how it is protected:
279
270
  - Default: compression enabled
280
271
  - Set `1` to disable compression when writing payloads.
281
272
  - Reads still decompress existing payloads.
273
+ - To skip compression only for one run's arguments, pass `compressArguments: false` to [`start()`](/docs/api-reference/workflow-api/start) instead.
282
274
 
283
275
  ### `WORKFLOW_COMPRESSION_CODEC`
284
276
 
@@ -314,7 +314,7 @@ Platform-provided values such as `VERCEL_DEPLOYMENT_ID`, `VERCEL_PROJECT_ID`, an
314
314
  - Default: on
315
315
  - Set to `0` (or `false`) to **disable** batched event writes, the escape hatch that restores the exact prior one-write-per-event path.
316
316
 
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.
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. 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.
318
318
 
319
319
  ### `WORKFLOW_EVENTS_TRANSPORT`
320
320
 
@@ -365,6 +365,8 @@ export default createWorld({
365
365
  WORKFLOW_TARGET_WORLD="./my-world.ts"
366
366
  ```
367
367
 
368
+ Pass `dispatcher` (for example an undici `Agent`) to replace the World's HTTP dispatchers, including the queue's and the one for stream writes. The default stream writer retries a write that was rejected with a 429 (after its `Retry-After`) or that failed to connect, sending a fresh request each time. A custom dispatcher turns that retry off. Don't configure a custom dispatcher to retry stream write `PUT` requests itself, because a retry after a 5xx or a dropped connection can append a chunk the server already stored.
369
+
368
370
  ## Versioning
369
371
 
370
372
  On Vercel, workflow runs are pegged to the deployment that started them. This means:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workflow",
3
- "version": "5.2.1",
3
+ "version": "5.2.2",
4
4
  "description": "Workflow SDK - Build durable, resilient, and observable workflows",
5
5
  "main": "dist/typescript-plugin.cjs",
6
6
  "type": "module",
@@ -58,19 +58,19 @@
58
58
  }
59
59
  },
60
60
  "dependencies": {
61
- "@workflow/astro": "5.0.4",
62
- "@workflow/cli": "5.0.4",
63
- "@workflow/core": "5.2.1",
61
+ "@workflow/astro": "5.0.5",
62
+ "@workflow/cli": "5.0.5",
63
+ "@workflow/core": "5.2.2",
64
64
  "@workflow/errors": "5.0.4",
65
65
  "@workflow/typescript-plugin": "5.0.0",
66
66
  "@workflow/utils": "5.0.2",
67
67
  "ms": "2.1.3",
68
- "@workflow/next": "5.0.4",
69
- "@workflow/nest": "5.1.2",
70
- "@workflow/nitro": "5.0.4",
71
- "@workflow/nuxt": "5.0.4",
72
- "@workflow/sveltekit": "5.0.4",
73
- "@workflow/rollup": "5.0.4"
68
+ "@workflow/next": "5.0.5",
69
+ "@workflow/nest": "5.1.3",
70
+ "@workflow/nitro": "5.0.5",
71
+ "@workflow/nuxt": "5.0.5",
72
+ "@workflow/sveltekit": "5.0.5",
73
+ "@workflow/rollup": "5.0.5"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/ms": "2.1.0",