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.
Files changed (60) hide show
  1. package/dist/observability.d.ts +1 -1
  2. package/dist/observability.d.ts.map +1 -1
  3. package/dist/observability.js +2 -2
  4. package/docs/ai/chat-session-modeling.mdx +1 -1
  5. package/docs/ai/resumable-streams.mdx +1 -1
  6. package/docs/api-reference/workflow/create-hook.mdx +3 -3
  7. package/docs/api-reference/workflow/create-webhook.mdx +1 -1
  8. package/docs/api-reference/workflow/fetch.mdx +1 -5
  9. package/docs/api-reference/workflow/get-step-metadata.mdx +19 -0
  10. package/docs/api-reference/workflow-ai/durable-agent.mdx +2 -1
  11. package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +4 -4
  12. package/docs/api-reference/workflow-api/get-hook-by-token.mdx +2 -2
  13. package/docs/api-reference/workflow-api/resume-hook.mdx +2 -2
  14. package/docs/api-reference/workflow-api/start.mdx +12 -8
  15. package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +2 -2
  16. package/docs/api-reference/workflow-errors/index.mdx +1 -1
  17. package/docs/api-reference/workflow-errors/workflow-run-cancelled-error.mdx +1 -1
  18. package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +1 -1
  19. package/docs/api-reference/workflow-errors/workflow-start-error.mdx +5 -5
  20. package/docs/api-reference/workflow-next/with-workflow.mdx +57 -0
  21. package/docs/api-reference/workflow-observability/create-state-resolver.mdx +56 -0
  22. package/docs/api-reference/workflow-observability/index.mdx +5 -0
  23. package/docs/api-reference/workflow-observability/meta.json +1 -0
  24. package/docs/api-reference/workflow-runtime/world/storage.mdx +2 -3
  25. package/docs/changelog/attributes-mvp.mdx +1 -1
  26. package/docs/changelog/batched-event-writes.mdx +0 -2
  27. package/docs/changelog/eager-processing.mdx +3 -1
  28. package/docs/changelog/lazy-event-creation.md +1 -1
  29. package/docs/changelog/spec-9.mdx +268 -120
  30. package/docs/changelog/step-message-ownership.mdx +2 -7
  31. package/docs/configuration/build-and-diagnostics.mdx +2 -0
  32. package/docs/configuration/cli-and-web-ui.mdx +13 -2
  33. package/docs/configuration/framework-options.mdx +7 -0
  34. package/docs/configuration/runtime-tuning.mdx +26 -74
  35. package/docs/configuration/worlds.mdx +55 -23
  36. package/docs/cookbook/advanced/child-workflows.mdx +126 -186
  37. package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +1 -1
  38. package/docs/cookbook/common-patterns/idempotency.mdx +2 -2
  39. package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +1 -1
  40. package/docs/cookbook/common-patterns/workflow-composition.mdx +5 -5
  41. package/docs/cookbook/integrations/ai-sdk.mdx +2 -2
  42. package/docs/errors/corrupted-event-log.mdx +1 -1
  43. package/docs/errors/fetch-in-workflow.mdx +15 -35
  44. package/docs/errors/hook-force-claimed.mdx +1 -1
  45. package/docs/errors/runtime-decryption-failed.mdx +1 -1
  46. package/docs/foundations/errors-and-retries.mdx +3 -1
  47. package/docs/foundations/hooks.mdx +1 -1
  48. package/docs/foundations/idempotency.mdx +11 -11
  49. package/docs/foundations/serialization.mdx +80 -0
  50. package/docs/foundations/starting-workflows.mdx +3 -7
  51. package/docs/getting-started/next.mdx +2 -0
  52. package/docs/how-it-works/event-sourcing.mdx +2 -2
  53. package/docs/observability/index.mdx +2 -0
  54. package/docs/whats-new.mdx +4 -4
  55. package/docs/worlds/building-a-world.mdx +22 -7
  56. package/docs/worlds/local.mdx +11 -7
  57. package/docs/worlds/postgres.mdx +17 -24
  58. package/docs/worlds/upgrading-to-v5.mdx +3 -3
  59. package/docs/worlds/vercel.mdx +13 -12
  60. package/package.json +14 -14
@@ -232,6 +232,8 @@ Unlike the [Vercel World](/worlds/vercel), which authenticates and [encrypts](/d
232
232
 
233
233
  `POST /.well-known/workflow/v1/flow` is where the worker delivers workflow orchestration and queued step invocations. It is mounted in your application like any other route, so it is publicly reachable by default, and it accepts any request whose headers and body are well-formed: there is no signature, shared secret, or caller check. Anyone who can reach it can forge or replay a workflow or step invocation, including steps your application would only reach after its own gating. Restrict it before you expose the app.
234
234
 
235
+ The runtime does not check deliveries to this route with a [queue key](/worlds/building-a-world#authenticating-deliveries): the Postgres World declares `queueAuthMode: 'skip'` until its messages are delivered in-process and the route is denied ([#5258](https://github.com/vercel/workflow/issues/5258)).
236
+
235
237
  The other routes under `/.well-known/workflow/v1/` differ:
236
238
 
237
239
  - `webhook/:token`, created by [`createWebhook()`](/docs/api-reference/workflow/create-webhook), is authorized by the token in the URL and nothing else. Use [`createHook()`](/docs/api-reference/workflow/create-hook) behind your own authenticated route and [`resumeHook()`](/docs/api-reference/workflow-api/resume-hook) when you need more than that.
@@ -285,10 +287,9 @@ The defaults work for a single process on a local database, so most apps set onl
285
287
  | [`WORKFLOW_POSTGRES_POLL_INTERVAL_MS`](#workflow_postgres_poll_interval_ms) | `500` ms | Idle job polling |
286
288
  | [`WORKFLOW_POSTGRES_MAX_POOL_SIZE`](#workflow_postgres_max_pool_size) | `10` | Connection pool size |
287
289
  | [`WORKFLOW_POSTGRES_APPLICATION_MANAGED_SHUTDOWN`](#workflow_postgres_application_managed_shutdown) | off | Who coordinates shutdown |
288
- | [`WORKFLOW_POSTGRES_RUN_STATUS_POLL_INTERVAL_MS`](#workflow_postgres_run_status_poll_interval_ms) | `1000` ms | Backstop for `await run.returnValue` |
289
290
  | [`WORKFLOW_POSTGRES_HEADERS_TIMEOUT_MS`](#workflow_postgres_headers_timeout_ms) | `0` ms (no deadline) | Hung delivery detection |
290
291
  | [`WORKFLOW_POSTGRES_BODY_TIMEOUT_MS`](#workflow_postgres_body_timeout_ms) | `0` ms (no deadline) | Stalled response detection |
291
- | [`WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS`](#workflow_postgres_job_lock_stale_seconds) | `0` s (off) | Redelivery after a process dies |
292
+ | [`WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS`](#workflow_postgres_job_lock_stale_seconds) | unset: 300 s for spec 9 named queues only | Redelivery after a process dies |
292
293
  | [`WORKFLOW_POSTGRES_HOOK_RETENTION_LIMIT_DAYS`](#workflow_postgres_hook_retention_limit_days) | `30` days | Maximum hook retention |
293
294
  | [`WORKFLOW_QUEUE_NAMESPACE`](#workflow_queue_namespace) | unset | Queue topic namespace |
294
295
  | [`WORKFLOW_STREAM_FLUSH_INTERVAL_MS`](#workflow_stream_flush_interval_ms) | `0` ms | Stream write batching |
@@ -315,7 +316,7 @@ Set the prefix through `WORKFLOW_POSTGRES_JOB_PREFIX` rather than only in code.
315
316
 
316
317
  Number of concurrent workers polling for jobs. Default: `50`.
317
318
 
318
- This value also bounds how many parent→child workflow polls can be in flight simultaneously. Every `await childRun.returnValue` inside a workflow holds a worker slot until the child run terminates. If you expect recursive or highly-fanned-out parent/child workflows, raise this ceiling above the peak number of concurrent polls. With the default of 50, the included `fibonacciWorkflow` end-to-end test (`fib(6)`, about 24 concurrent polls at peak) passes; deeper recursion or larger fanouts need a correspondingly larger setting.
319
+ A parent workflow awaiting `childRun.returnValue` of a child it started does not hold a worker slot: it suspends on a system hook the child resumes when it finishes (see [Child Workflows](/cookbook/advanced/child-workflows#how-the-parent-waits)). A `returnValue` that falls back to polling still does, for example one awaited inside a step, or any await while `WORKFLOW_CHILD_RUN_COMPLETION_HOOK=0` is set. Each of those holds a worker slot until its child run terminates, so raise this ceiling above the peak number of such polls in flight.
319
320
 
320
321
  ### `WORKFLOW_POSTGRES_POLL_INTERVAL_MS`
321
322
 
@@ -331,12 +332,6 @@ For higher worker concurrency, Graphile Worker recommends setting `maxPoolSize`
331
332
 
332
333
  Set to `1` when the application or framework coordinates shutdown and awaits `world.close()` before closing its workflow HTTP server and any caller-owned pool. Default: unset (`false`).
333
334
 
334
- ### `WORKFLOW_POSTGRES_RUN_STATUS_POLL_INTERVAL_MS`
335
-
336
- How often a wait for a terminal run status re-reads the run, in milliseconds. Default: `1000`.
337
-
338
- `await run.returnValue` asks the World to wait for the run to finish, and the Postgres World parks that wait on a `NOTIFY` issued by the run-terminal write. This interval is only the backstop: it bounds how long a lost notification can go unnoticed, so lowering it costs a query per waiting run per interval and buys nothing while notifications are arriving.
339
-
340
335
  ### `WORKFLOW_POSTGRES_HEADERS_TIMEOUT_MS`
341
336
 
342
337
  Maximum time in milliseconds a queue delivery waits for the workflow handler to begin responding before the delivery is failed and Graphile Worker redelivers the message. Default: `0` (no deadline).
@@ -349,30 +344,22 @@ Maximum gap in milliseconds between response body chunks from the workflow handl
349
344
 
350
345
  ### `WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS`
351
346
 
352
- Seconds a running delivery's job lock may go unrenewed before another process releases the job for redelivery. Default: `0` (off). `30` is a good value when more than one process shares the database. Programmatic option: `jobLockStaleSeconds`.
347
+ Seconds a running delivery's job lock may go unrenewed before another process releases the job for redelivery. Default: unset (see below). `30` is a good value when more than one process shares the database. Programmatic option: `jobLockStaleSeconds`.
353
348
 
354
- When set, a running delivery renews its lock every quarter of this window, and at least every 10 seconds. When a process dies mid-delivery, another process redelivers its jobs within about one and a half windows (about 45 seconds at `30`), instead of after Graphile Worker's fixed 4 hour stale-lock reset or the next restart.
349
+ A running delivery renews its lock every quarter of the window, and at least every 10 seconds. When a process dies mid-delivery, another process redelivers its jobs within about one and a half windows (about 45 seconds at `30`), instead of after Graphile Worker's fixed 4 hour stale-lock reset or the next restart.
350
+
351
+ Unset, every delivery still renews its lock, and its worker registers as renewing in `workflow.workflow_job_lock_holders` (migration 0030, which `bootstrap` applies). Then only the jobs of a spec 9 run's named queue (its orchestrator deliveries, and invoke mode's executor lane) are released, after 300 seconds unrenewed, and only those whose holder registered. A spec 9 run whose worker was killed therefore continues within about 8 minutes (one and a half windows) instead of 4 hours. A job held by a process on an earlier version, which does not register, is never released this way, so the default is safe during a rolling upgrade. `0` turns renewal and release off.
355
352
 
356
353
  Use the same value on every process that shares the database, and keep it well above the longest a process can go without running its timers (synchronous work that blocks the event loop) or getting a pool connection. A delivery whose renewals stall past the window is redelivered while it still runs.
357
354
 
358
- It's off by default because of rolling upgrades. A process on an earlier version doesn't renew its locks, so a process that has this on would redeliver any of that process's deliveries that run longer than the window. When the earlier-version process then finishes such a delivery, its acknowledgement, which isn't fenced on the lock holder, can delete the redelivered job's row, and the redelivery loses its retry.
355
+ Setting it releases every job of this World, whoever holds it, so set it only after a rolling upgrade has finished. A process on an earlier version doesn't renew its locks, so a process that has this set would redeliver any of that process's deliveries that run longer than the window. When the earlier-version process then finishes such a delivery, its acknowledgement, which isn't fenced on the lock holder, can delete the redelivered job's row, and the redelivery loses its retry.
359
356
 
360
- To turn it on, set `WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS=30` (or `jobLockStaleSeconds: 30`) on every process that shares the database, once all of them run a version that includes this option.
357
+ To set it, use `WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS=30` (or `jobLockStaleSeconds: 30`) on every process that shares the database, once all of them run a version that includes this option.
361
358
 
362
359
  ### `WORKFLOW_POSTGRES_HOOK_RETENTION_LIMIT_DAYS`
363
360
 
364
361
  Maximum [`experimental_minRetention`](/docs/api-reference/workflow/create-hook#keep-a-token-unavailable-after-the-run-ends) accepted by the Postgres World, in days. Default: `30`. Set this to the same limit as your production World so oversized values fail during development.
365
362
 
366
- ### `WORKFLOW_POSTGRES_EXPERIMENTAL_START_HOOK`
367
-
368
- Set to `1` (or `true`) to enable [`start({ hook })`](/docs/api-reference/workflow-api/start#prevent-duplicate-starts) on the Postgres World. Off by default; without it, `start({ hook })` throws before it enqueues anything.
369
-
370
- Stop workers running a previous version before you turn it on. The queue does not route by deployment, so an older worker that picks up a candidate's queued message would create its run without the start Hook, and the start would no longer be idempotent (`start()` reports that the World did not confirm the start Hook). An older runtime replaying a start Hook run can't bind the workflow's `createHook({ token })` to the start Hook either.
371
-
372
- For the same reason, don't roll back past migration `0028_add_start_hook_admissions` while start Hooks are live.
373
-
374
- Migration `0028_add_start_hook_admissions` is required even with this variable unset, because every Hook insert writes its `claims_token` column. It takes table locks on `workflow_hooks` and then `workflow_runs` (building the new unique index scans `workflow_hooks` first), and gives up after 10 seconds (unless the session sets its own `lock_timeout`), leaving the migration to retry, rather than stall traffic. Apply it with the rest of the migrations before deploying this version.
375
-
376
363
  ### `WORKFLOW_QUEUE_NAMESPACE`
377
364
 
378
365
  Queue topic namespace shared by build output and the Postgres World. Default: unset.
@@ -405,6 +392,12 @@ at most 10 seconds for its locks; if a long transaction holds them,
405
392
  `bootstrap` fails and can be run again.
406
393
  </Callout>
407
394
 
395
+ ### Start Hooks
396
+
397
+ Migration `0028_add_start_hook_admissions` adds [`start({ experimental_hook })`](/docs/api-reference/workflow-api/start#prevent-duplicate-starts) support. It is required for every Postgres World on this version, because every Hook insert writes its `claims_token` column. It takes table locks on `workflow_hooks` and then `workflow_runs` (building the new unique index scans `workflow_hooks` first), and gives up after 10 seconds (unless the session sets its own `lock_timeout`), leaving the migration to retry, rather than stall traffic. Apply it with the rest of the migrations before deploying this version.
398
+
399
+ Stop workers running a previous version before your app passes `experimental_hook` to `start()`. The queue does not route by deployment, so an older worker that picks up a candidate's queued message would create its run without the start Hook, and the start would no longer be idempotent (`start()` reports that the World did not confirm the start Hook). An older runtime replaying a start Hook run can't bind the workflow's `createHook({ token })` to the start Hook either. For the same reason, don't roll back past migration `0028_add_start_hook_admissions` while start Hooks are in use.
400
+
408
401
  ## Advanced
409
402
 
410
403
  Most apps don't need anything in this section. It covers building your own World module, sharing the queue with other consumers, coordinating shutdown yourself, and an experimental delivery mode.
@@ -494,7 +487,7 @@ The Postgres World uses PostgreSQL as a durable backend:
494
487
 
495
488
  - **Storage**: Workflow runs, events, steps, and hooks are stored in PostgreSQL tables.
496
489
  - **Job queue**: [graphile-worker](https://github.com/graphile/worker) handles reliable job processing with retries.
497
- - **Crash recovery**: The next `start()` re-enqueues active runs. With [`WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS`](#workflow_postgres_job_lock_stale_seconds) set, a running delivery also renews its job lock, and if its process dies, any other process redelivers the job once its lock has gone unrenewed for that many seconds.
490
+ - **Crash recovery**: The next `start()` re-enqueues active runs. A running delivery also renews its job lock. If its process dies, any other process redelivers a spec 9 run's orchestrator job once its lock has gone unrenewed for 300 seconds, and with [`WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS`](#workflow_postgres_job_lock_stale_seconds) set, any job of this World once its lock has gone unrenewed for that many seconds.
498
491
  - **Streaming**: PostgreSQL NOTIFY/LISTEN enables real-time event distribution. If the database drops the `LISTEN` connection, the World reconnects every second and re-reads persisted chunks for open stream readers, so readers don't miss chunks written during the outage.
499
492
 
500
493
  This architecture ensures workflows survive application restarts with all state reliably persisted. For implementation details, see the [source code](https://github.com/vercel/workflow/tree/main/packages/world-postgres).
@@ -52,7 +52,7 @@ export function createWorld(): World {
52
52
 
53
53
  In v4 the runtime required that number to equal its own current version exactly. In v5 it checks the declaration against a range before it creates or replays anything, and refuses a World outside it with an error naming both the range and what your World declared. The floor is the version that introduced [slot-numbered event IDs](#event-id-allocation), because a World below it allocates IDs the runtime cannot read positions out of, and admitting one would only move the failure from startup into the middle of a run. The ceiling is the highest version this runtime can read.
54
54
 
55
- `mintedSpecVersion()` is a function rather than a constant because the version a World stamps is a deployment-level choice. It answers with the sealed-log version by default, and with the slot-identity version when [`WORKFLOW_SEALED_LOG=0`](/docs/configuration/runtime-tuning#workflow_sealed_log) opts new runs out. Both sit inside the accepted range, so either answer is a valid declaration. Reading it per `createWorld()` call rather than once at module load is what lets a single process create Worlds in both modes.
55
+ `mintedSpecVersion()` is a function rather than a constant because the version a World stamps is a deployment-level choice. It answers with the sealed-log version by default, and with the version [`WORKFLOW_SPEC_VERSION`](/docs/configuration/runtime-tuning#workflow_spec_version) selects, such as the slot-identity version (6), when that is set. Every version it accepts sits inside the accepted range, so any answer is a valid declaration. Reading it per `createWorld()` call rather than once at module load is what lets a single process create Worlds with different settings.
56
56
 
57
57
  Calling it is also what keeps the check passing across upgrades, since it moves with the `@workflow/world` version your package resolves. A hard-coded number leaves your World a version behind the next bump and gets it rejected by the runtime it ships alongside. That includes the constants: `SPEC_VERSION_CURRENT` and `SPEC_VERSION_SUPPORTS_SLOT_IDENTITY` are literals by another name for this purpose, since neither follows the sealed-log setting. Keep `@workflow/world` in the same release channel as the `workflow` version your users install.
58
58
 
@@ -63,7 +63,7 @@ The sealed-log version exists for a World whose store makes allocating a positio
63
63
  Two consequences for an implementation:
64
64
 
65
65
  - **If you allocate at the commit, you are already compliant** and have nothing to build. No write can leave a position empty, so you have no holes to seal and will never emit a `noop`. `@workflow/world-local` and `@workflow/world-postgres` are in this position.
66
- - **What the version actually gates is the reader.** A run stamped at the sealed-log version can only be replayed by a reader that knows to skip `noop`. That is every runtime on this release train, but a runtime pinning its own accepted range separately, such as the Python runtime, has to catch up first. `WORKFLOW_SEALED_LOG=0` is the switch for an environment where it has not.
66
+ - **What the version actually gates is the reader.** A run stamped at the sealed-log version can only be replayed by a reader that knows to skip `noop`. That is every runtime on this release train, but a runtime pinning its own accepted range separately, such as the Python runtime, has to catch up first. `WORKFLOW_SPEC_VERSION=6` is the setting for an environment where it has not.
67
67
 
68
68
  Runs carry a spec version too, and a run keeps the version it was created under for its whole life. Read the stamped version off the run rather than assuming every run matches what your World declares today. Changing what you stamp does not reach runs already in your store: their version is persisted, every version test in the runtime is a lower bound, and a run's event ID scheme is resolved from what is stored.
69
69
 
@@ -152,7 +152,7 @@ None of this is required. Each entry is a hook the runtime uses if your World pr
152
152
  | `close()` | Releases connection pools and listeners so CLI commands and short-lived processes can exit without `process.exit()`. |
153
153
  | `streams.streamFlushIntervalMs` | Sets the stream flush window. The v5 default is `0`, so the first chunk flushes immediately; set a value to coalesce writes again. |
154
154
  | Hook token retention | `Hook.tokenRetentionUntil` marks the earliest time a token may become available after its run ends. Keep the owning run readable at least that long, and honor `hook_disposed` as an immediate release. Declare `capabilities.hookRetention.active` only once this is implemented, since the runtime otherwise rejects retained hooks before registration. |
155
- | Atomic start Hooks | Backs [`start({ hook })`](/docs/api-reference/workflow-api/start#prevent-duplicate-starts): admit a run and create its start Hook in one atomic step, so a duplicate start is refused naming the owner and the start Hook can be resumed from admission. Declare `capabilities.atomicStartHook.active` only once you implement [the contract](/worlds/building-a-world#optional-atomic-start-hook-admission). |
155
+ | Atomic start Hooks | Backs [`start({ experimental_hook })`](/docs/api-reference/workflow-api/start#prevent-duplicate-starts): admit a run and create its start Hook in one atomic step, so a duplicate start is refused naming the owner and the start Hook can be resumed from admission. Declare `capabilities.atomicStartHook.active` only once you implement [the contract](/worlds/building-a-world#optional-atomic-start-hook-admission). |
156
156
  | Hook resume dedup | `resumeHook()` writes `hook_received` and dispatches the queue message in parallel when the backend collapses concurrent writes carrying the same `(runId, resumeId)` onto one committed event. Declare `capabilities.hookResumeDedup` only if you enforce that constraint **and** `events.list()` returns the committed event's top-level `resumeId`. A World that omits either guarantee must leave the flag unset, which keeps the sequential path. See [Durable hook resume](/docs/changelog/lazy-hook-resume). |
157
157
  | Resolved hook resume | Lets `resumeHook()` deliver to a stored [`Hook`](/docs/api-reference/workflow-api/resume-hook#reuse-a-resolved-hook) without looking up its token again. Declare `capabilities.resolvedHookResume` only if a write carrying `requireHookResumeDedup` either commits with atomic resume deduplication or is refused (400/404) before anything is written. The runtime then looks the token up and delivers as usual. Without the flag, a stored Hook is delivered through the existing path. |
158
158
  | Hook token takeover | Backs [`createHook({ experimental_force: true })`](/docs/api-reference/workflow/create-hook#take-over-a-token-another-run-holds). When a forced `hook_created` names a token another live run holds, append `hook_disposed` with `forceClaimedBy: { runId, hookId }` to the holder's log and refuse later `hook_received` writes to it, then re-point the token to the claimer and record `Hook.claimedFrom`. Refuse the takeover with an ordinary `hook_conflict` carrying `forceRefusedReason: 'victim-spec-version'` when the holder was stamped below spec version 8, and answer a `hook_received` refused by a takeover with `HookForceClaimedError` so `resumeHook()` can follow the token. Declare `capabilities.hookForceClaim` only once you give these guarantees. Without it, the runtime fails a forced `createHook()` at registration. |
@@ -158,7 +158,7 @@ The route serves `world.createQueueHandler("__agent_wkf_workflow_", handler)`. T
158
158
  ## Limitations
159
159
 
160
160
  - **No run migration**: A run's region is fixed at creation. Existing runs cannot be moved to a different region.
161
- - **Hook minimum retention**: `experimental_minRetention` cannot exceed 30 days, on both [`createHook()`](/docs/api-reference/workflow/create-hook#keep-a-token-unavailable-after-the-run-ends) and [`start({ hook })`](/docs/api-reference/workflow-api/start#prevent-duplicate-starts).
161
+ - **Hook minimum retention**: `experimental_minRetention` cannot exceed 30 days, on both [`createHook()`](/docs/api-reference/workflow/create-hook#keep-a-token-unavailable-after-the-run-ends) and [`start({ experimental_hook })`](/docs/api-reference/workflow-api/start#prevent-duplicate-starts).
162
162
 
163
163
  ## Observability
164
164
 
@@ -176,7 +176,7 @@ npx workflow inspect runs --backend vercel
176
176
  npx workflow web --backend vercel
177
177
  ```
178
178
 
179
- The CLI automatically retrieves authentication from the Vercel CLI (`vercel login`) and infers project/team IDs from your local Vercel project linking.
179
+ The CLI automatically retrieves authentication from the Vercel CLI (`vercel login`) and infers project/team IDs from your local Vercel project linking. In a monorepo, it uses the nearest `.vercel/project.json`.
180
180
 
181
181
  To use the local observability UI instead of the Vercel dashboard:
182
182
 
@@ -184,7 +184,7 @@ To use the local observability UI instead of the Vercel dashboard:
184
184
  npx workflow web --backend vercel --localUi
185
185
  ```
186
186
 
187
- To override the automatic configuration:
187
+ To override the automatic configuration, pass the values explicitly. `--project` and `--team` take precedence over the linked project:
188
188
 
189
189
  ```bash
190
190
  npx workflow inspect runs \
@@ -378,11 +378,7 @@ The Vercel World doesn't follow HTTP redirects on workflow API requests, so poin
378
378
 
379
379
  ### `VERCEL_WORKFLOW_SERVER_URL`
380
380
 
381
- Custom workflow-server URL for direct runtime requests, or for the proxy to forward to via `WORKFLOW_VERCEL_BACKEND_URL`. Default: unset; normal deployments should not need this.
382
-
383
- ### `WORKFLOW_VERCEL_EXPERIMENTAL_START_HOOK`
384
-
385
- Set to `1` (or `true`) to enable [`start({ hook })`](/docs/api-reference/workflow-api/start#prevent-duplicate-starts) on the Vercel World. Off by default; without it, `start({ hook })` throws before it enqueues anything. It needs a backend that supports start Hooks. Set it on the deployment that starts runs and on any deployment those runs target.
381
+ Custom backend URL for direct runtime requests, or for the proxy to forward to via `WORKFLOW_VERCEL_BACKEND_URL`. Default: unset; normal deployments should not need this.
386
382
 
387
383
  ### `WORKFLOW_SEQUENTIAL_REPLAYS`
388
384
 
@@ -404,13 +400,11 @@ Vercel Queues can delay messages for up to 7 days, capped by the message TTL. Be
404
400
 
405
401
  ### `WORKFLOW_REQUEST_TIMEOUT_MS`
406
402
 
407
- Per-request timeout, in milliseconds, for Vercel World HTTP calls to workflow-server. Default: `60000`. Clamped to `10000`-`120000`; a value outside that range is pulled into it and warns once.
403
+ Per-request timeout, in milliseconds, for Vercel World HTTP calls to its backend. Default: `60000`. Clamped to `10000`-`120000`; a value outside that range is pulled into it and warns once.
408
404
 
409
405
  Below the floor the deadline starts canceling requests that would have succeeded, since a cold route or a large event page can take seconds, and a canceled request is redriven through the queue rather than making progress. The ceiling matches the longest a backend route holds a response. Requests that legitimately outlast it (stream reads and writes, event batches) opt out of the deadline entirely rather than relying on this value.
410
406
 
411
- ### `WORKFLOW_MAX_CHUNKS_PER_REQUEST`
412
-
413
- Maximum stream chunks written in one Vercel World request. Larger batches are split across multiple requests. Default: `1000`. Minimum: `1`.
407
+ The same deadline bounds the [events WebSocket](#workflow_events_transport): opening the socket, including resolving the token it is opened with, and each event write over it.
414
408
 
415
409
  ### `WORKFLOW_STREAMS_TRANSPORT`
416
410
 
@@ -460,11 +454,16 @@ try {
460
454
 
461
455
  `openEventsChannel()` returns `undefined`, and writes stay on HTTP, when the transport is disabled or the World cannot hold a socket, such as a `projectConfig` World.
462
456
 
457
+ A write issued while the channel's socket is still connecting waits for the handshake, except `run_started`, which goes over HTTP instead. It is a delivery's first write, and every later write of the delivery waits for it.
458
+
459
+ If the first connect fails, or opening the socket or a write over it gets no answer within [`WORKFLOW_REQUEST_TIMEOUT_MS`](#workflow_request_timeout_ms), the channel closes. The write that failed is retried over HTTP where the event type allows a retry, and every later event write for that run goes over HTTP until a new channel is opened, which the next delivery does. The channel is shared by every concurrent invocation of the run in the same process, so one timed out write moves all of them to HTTP, and releasing it afterwards has nothing left to close.
460
+
463
461
  Tracing is unaffected by the choice. Each event write emits an `http POST` client span against the same `url.full`, regardless of which transport carries it. On the WebSocket path, the span is synthesized around the frame because no HTTP request is made. Attributes distinguish the transports:
464
462
 
465
463
  | Attribute | HTTP | WebSocket |
466
464
  | --- | --- | --- |
467
465
  | `workflow.events.transport` | `http` | `ws` |
466
+ | `workflow.events.transport_fallback` | why a write that tried the socket went over HTTP: `no_channel` (no socket for the run) or `connecting` (a `run_started` during the handshake). Absent when the write never tried the socket, and through a `projectConfig` World. | — |
468
467
  | `workflow.event.type` | the event type, e.g. `step_started` | same |
469
468
  | `network.protocol.name` | — | `websocket` |
470
469
  | `workflow.events.ws.url` | — | the socket the frame went over |
@@ -558,6 +557,8 @@ Practically, this means:
558
557
  - Only messages delivered through Vercel Queues can trigger execution
559
558
  - Handlers receive only a message ID that must be retrieved from Vercel's backend, making it impossible to craft custom payloads
560
559
 
560
+ These two layers, a route only Vercel Queues can trigger and a handler that takes a message ID and retrieves and leases the message through Vercel Queues, are why the Vercel World declares `queueAuthMode: 'skip'`: the runtime does not also check a [queue key](/worlds/building-a-world#authenticating-deliveries) on its deliveries. A custom World should declare `'skip'` only when its platform provides both layers.
561
+
561
562
  <Callout>
562
563
  The Workflow SDK build step manages this configuration. If you are writing a custom integration, see [Framework integrations: Security](/docs/how-it-works/framework-integrations#security) for more details.
563
564
  </Callout>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workflow",
3
- "version": "5.3.0",
3
+ "version": "5.5.0",
4
4
  "description": "Workflow SDK - Build durable, resilient, and observable workflows",
5
5
  "main": "dist/typescript-plugin.cjs",
6
6
  "type": "module",
@@ -58,23 +58,23 @@
58
58
  }
59
59
  },
60
60
  "dependencies": {
61
- "@workflow/astro": "5.0.7",
62
- "@workflow/cli": "5.0.7",
63
- "@workflow/core": "5.3.0",
64
- "@workflow/errors": "5.1.0",
61
+ "@workflow/astro": "5.0.9",
62
+ "@workflow/cli": "5.1.0",
63
+ "@workflow/core": "5.5.0",
64
+ "@workflow/errors": "5.1.1",
65
65
  "@workflow/typescript-plugin": "5.0.0",
66
- "@workflow/utils": "5.0.2",
66
+ "@workflow/utils": "5.1.0",
67
67
  "ms": "2.1.3",
68
- "@workflow/next": "5.0.7",
69
- "@workflow/nest": "5.1.5",
70
- "@workflow/nitro": "5.0.7",
71
- "@workflow/nuxt": "5.0.7",
72
- "@workflow/sveltekit": "5.0.7",
73
- "@workflow/rollup": "5.0.7"
68
+ "@workflow/next": "5.1.0",
69
+ "@workflow/nest": "5.1.7",
70
+ "@workflow/nitro": "5.0.9",
71
+ "@workflow/nuxt": "5.0.9",
72
+ "@workflow/sveltekit": "5.0.9",
73
+ "@workflow/rollup": "5.0.9"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/ms": "2.1.0",
77
- "@types/node": "22.19.0",
77
+ "@types/node": "22.19.21",
78
78
  "@workflow/tsconfig": "5.0.0",
79
79
  "typescript": "^6.0.3"
80
80
  },
@@ -90,7 +90,7 @@
90
90
  "build": "tsc && chmod +x bin/run.js",
91
91
  "clean": "tsc --build --clean && rm -rf dist docs ||:",
92
92
  "dev": "tsc --watch",
93
- "test": "vitest run src",
93
+ "test": "vitest run --config=../../vitest.config.ts src",
94
94
  "typecheck": "tsc --noEmit"
95
95
  }
96
96
  }