workflow 5.0.0-beta.5 → 5.0.0-beta.51

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 (256) hide show
  1. package/README.md +68 -23
  2. package/dist/api-workflow.d.ts +1 -1
  3. package/dist/api-workflow.d.ts.map +1 -1
  4. package/dist/api-workflow.js +1 -1
  5. package/dist/api.d.ts +3 -3
  6. package/dist/api.d.ts.map +1 -1
  7. package/dist/api.js +5 -7
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +6 -1
  11. package/dist/internal/builtins.d.ts +20 -3
  12. package/dist/internal/builtins.d.ts.map +1 -1
  13. package/dist/internal/builtins.js +68 -4
  14. package/dist/internal/errors.d.ts +1 -1
  15. package/dist/internal/errors.d.ts.map +1 -1
  16. package/dist/internal/errors.js +2 -2
  17. package/dist/nest-builder.d.ts +2 -0
  18. package/dist/nest-builder.d.ts.map +1 -0
  19. package/dist/nest-builder.js +2 -0
  20. package/dist/nest-vercel-builder.d.ts +2 -0
  21. package/dist/nest-vercel-builder.d.ts.map +1 -0
  22. package/dist/nest-vercel-builder.js +2 -0
  23. package/dist/observability.d.ts +1 -1
  24. package/dist/observability.js +2 -2
  25. package/dist/runtime.d.ts +2 -1
  26. package/dist/runtime.d.ts.map +1 -1
  27. package/dist/runtime.js +4 -1
  28. package/docs/ai/chat-session-modeling.mdx +176 -422
  29. package/docs/ai/defining-tools.mdx +6 -7
  30. package/docs/ai/human-in-the-loop.mdx +11 -11
  31. package/docs/ai/index.mdx +71 -75
  32. package/docs/ai/message-queueing.mdx +71 -110
  33. package/docs/ai/meta.json +1 -0
  34. package/docs/ai/resumable-streams.mdx +40 -28
  35. package/docs/ai/sleep-and-delays.mdx +10 -10
  36. package/docs/ai/streaming-updates-from-tools.mdx +6 -6
  37. package/docs/api-reference/index.mdx +25 -1
  38. package/docs/api-reference/meta.json +8 -0
  39. package/docs/api-reference/vitest/index.mdx +9 -15
  40. package/docs/api-reference/workflow/create-hook.mdx +89 -10
  41. package/docs/api-reference/workflow/create-webhook.mdx +16 -15
  42. package/docs/api-reference/workflow/define-hook.mdx +35 -33
  43. package/docs/api-reference/workflow/fatal-error.mdx +30 -8
  44. package/docs/api-reference/workflow/fetch.mdx +14 -10
  45. package/docs/api-reference/workflow/get-step-metadata.mdx +2 -2
  46. package/docs/api-reference/workflow/get-workflow-metadata.mdx +3 -3
  47. package/docs/api-reference/workflow/get-writable.mdx +7 -7
  48. package/docs/api-reference/workflow/index.mdx +4 -1
  49. package/docs/api-reference/workflow/retryable-error.mdx +1 -1
  50. package/docs/api-reference/workflow/set-attributes.mdx +61 -0
  51. package/docs/api-reference/workflow/sleep.mdx +4 -4
  52. package/docs/api-reference/workflow-ai/durable-agent.mdx +63 -101
  53. package/docs/api-reference/workflow-ai/index.mdx +5 -5
  54. package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +67 -24
  55. package/docs/api-reference/workflow-api/get-hook-by-token.mdx +26 -12
  56. package/docs/api-reference/workflow-api/get-run.mdx +43 -8
  57. package/docs/api-reference/workflow-api/index.mdx +6 -10
  58. package/docs/api-reference/workflow-api/resume-hook.mdx +73 -12
  59. package/docs/api-reference/workflow-api/resume-webhook.mdx +11 -9
  60. package/docs/api-reference/workflow-api/start.mdx +60 -13
  61. package/docs/api-reference/workflow-astro/index.mdx +18 -0
  62. package/docs/api-reference/workflow-astro/meta.json +4 -0
  63. package/docs/api-reference/workflow-astro/workflow.mdx +45 -0
  64. package/docs/api-reference/workflow-errors/entity-conflict-error.mdx +4 -4
  65. package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +60 -0
  66. package/docs/api-reference/workflow-errors/hook-not-found-error.mdx +8 -8
  67. package/docs/api-reference/workflow-errors/index.mdx +88 -0
  68. package/docs/api-reference/workflow-errors/meta.json +6 -0
  69. package/docs/api-reference/workflow-errors/precondition-failed-error.mdx +68 -0
  70. package/docs/api-reference/workflow-errors/run-expired-error.mdx +2 -2
  71. package/docs/api-reference/workflow-errors/run-not-supported-error.mdx +58 -0
  72. package/docs/api-reference/workflow-errors/step-not-registered-error.mdx +5 -5
  73. package/docs/api-reference/workflow-errors/throttle-error.mdx +2 -2
  74. package/docs/api-reference/workflow-errors/too-early-error.mdx +2 -2
  75. package/docs/api-reference/workflow-errors/workflow-error.mdx +52 -0
  76. package/docs/api-reference/workflow-errors/workflow-not-registered-error.mdx +5 -6
  77. package/docs/api-reference/workflow-errors/workflow-run-cancelled-error.mdx +6 -6
  78. package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +5 -5
  79. package/docs/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +58 -0
  80. package/docs/api-reference/workflow-errors/workflow-run-not-found-error.mdx +4 -4
  81. package/docs/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
  82. package/docs/api-reference/workflow-errors/workflow-world-error.mdx +8 -8
  83. package/docs/api-reference/workflow-globals.mdx +14 -10
  84. package/docs/api-reference/workflow-nest/configure-workflow-controller.mdx +33 -0
  85. package/docs/api-reference/workflow-nest/index.mdx +31 -0
  86. package/docs/api-reference/workflow-nest/meta.json +9 -0
  87. package/docs/api-reference/workflow-nest/nest-local-builder.mdx +64 -0
  88. package/docs/api-reference/workflow-nest/workflow-controller.mdx +40 -0
  89. package/docs/api-reference/workflow-nest/workflow-module.mdx +74 -0
  90. package/docs/api-reference/workflow-next/with-workflow.mdx +39 -17
  91. package/docs/api-reference/workflow-nitro/index.mdx +60 -0
  92. package/docs/api-reference/workflow-nuxt/index.mdx +48 -0
  93. package/docs/api-reference/workflow-observability/hydrate-data.mdx +35 -0
  94. package/docs/api-reference/workflow-observability/hydrate-resource-io.mdx +62 -0
  95. package/docs/api-reference/workflow-observability/index.mdx +62 -0
  96. package/docs/api-reference/workflow-observability/meta.json +11 -0
  97. package/docs/api-reference/workflow-observability/observability-revivers.mdx +50 -0
  98. package/docs/api-reference/workflow-observability/parse-class-name.mdx +41 -0
  99. package/docs/api-reference/workflow-observability/parse-step-name.mdx +40 -0
  100. package/docs/api-reference/workflow-observability/parse-workflow-name.mdx +55 -0
  101. package/docs/api-reference/workflow-runtime/create-world.mdx +39 -0
  102. package/docs/api-reference/workflow-runtime/get-world-handlers.mdx +44 -0
  103. package/docs/api-reference/{workflow-api → workflow-runtime}/get-world.mdx +11 -14
  104. package/docs/api-reference/workflow-runtime/health-check.mdx +50 -0
  105. package/docs/api-reference/workflow-runtime/index.mdx +41 -0
  106. package/docs/api-reference/workflow-runtime/meta.json +12 -0
  107. package/docs/api-reference/workflow-runtime/set-world.mdx +51 -0
  108. package/docs/api-reference/workflow-runtime/workflow-entrypoint.mdx +43 -0
  109. package/docs/api-reference/workflow-runtime/world/analytics.mdx +315 -0
  110. package/docs/api-reference/workflow-runtime/world/index.mdx +60 -0
  111. package/docs/api-reference/workflow-runtime/world/meta.json +4 -0
  112. package/docs/api-reference/workflow-runtime/world/queue.mdx +88 -0
  113. package/docs/api-reference/{workflow-api → workflow-runtime}/world/storage.mdx +98 -34
  114. package/docs/api-reference/{workflow-api → workflow-runtime}/world/streams.mdx +8 -8
  115. package/docs/api-reference/workflow-serde/index.mdx +1 -2
  116. package/docs/api-reference/workflow-serde/workflow-deserialize.mdx +3 -4
  117. package/docs/api-reference/workflow-serde/workflow-serialize.mdx +8 -8
  118. package/docs/api-reference/workflow-sveltekit/index.mdx +18 -0
  119. package/docs/api-reference/workflow-sveltekit/meta.json +4 -0
  120. package/docs/api-reference/workflow-sveltekit/workflow-plugin.mdx +42 -0
  121. package/docs/api-reference/workflow-vite/index.mdx +18 -0
  122. package/docs/api-reference/workflow-vite/meta.json +4 -0
  123. package/docs/api-reference/workflow-vite/workflow.mdx +48 -0
  124. package/docs/changelog/attributes-mvp.mdx +380 -0
  125. package/docs/changelog/batched-event-writes.mdx +79 -0
  126. package/docs/changelog/eager-processing.mdx +110 -436
  127. package/docs/changelog/index.mdx +4 -2
  128. package/docs/changelog/lazy-event-creation.md +127 -0
  129. package/docs/changelog/lazy-hook-resume.mdx +78 -0
  130. package/docs/changelog/meta.json +11 -1
  131. package/docs/changelog/resilient-resume.mdx +32 -0
  132. package/docs/changelog/resilient-start.mdx +33 -285
  133. package/docs/changelog/step-message-ownership.mdx +360 -0
  134. package/docs/changelog/turbo-mode.md +87 -0
  135. package/docs/comparisons/index.mdx +66 -0
  136. package/docs/comparisons/meta.json +11 -0
  137. package/docs/comparisons/workflow-sdk-vs-aws-agentcore.mdx +55 -0
  138. package/docs/comparisons/workflow-sdk-vs-aws-step-functions.mdx +111 -0
  139. package/docs/comparisons/workflow-sdk-vs-cloudflare-workflows.mdx +71 -0
  140. package/docs/comparisons/workflow-sdk-vs-inngest.mdx +102 -0
  141. package/docs/comparisons/workflow-sdk-vs-temporal.mdx +123 -0
  142. package/docs/comparisons/workflow-sdk-vs-trigger-dev.mdx +104 -0
  143. package/docs/configuration/build-and-diagnostics.mdx +70 -0
  144. package/docs/configuration/cli-and-web-ui.mdx +241 -0
  145. package/docs/configuration/framework-options.mdx +165 -0
  146. package/docs/configuration/index.mdx +32 -0
  147. package/docs/configuration/meta.json +12 -0
  148. package/docs/configuration/runtime-tuning.mdx +381 -0
  149. package/docs/configuration/worlds.mdx +313 -0
  150. package/docs/cookbook/advanced/child-workflows.mdx +211 -264
  151. package/docs/cookbook/advanced/meta.json +6 -1
  152. package/docs/cookbook/advanced/publishing-libraries.mdx +65 -56
  153. package/docs/cookbook/advanced/serializable-steps.mdx +48 -68
  154. package/docs/cookbook/advanced/upgrading-workflows.mdx +199 -0
  155. package/docs/cookbook/agent-patterns/agent-cancellation.mdx +78 -60
  156. package/docs/cookbook/agent-patterns/durable-agent.mdx +23 -131
  157. package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +180 -195
  158. package/docs/cookbook/common-patterns/batching.mdx +18 -14
  159. package/docs/cookbook/common-patterns/idempotency.mdx +41 -53
  160. package/docs/cookbook/common-patterns/rate-limiting.mdx +8 -4
  161. package/docs/cookbook/common-patterns/saga.mdx +23 -19
  162. package/docs/cookbook/common-patterns/scheduling.mdx +34 -22
  163. package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +29 -25
  164. package/docs/cookbook/common-patterns/timeouts.mdx +26 -21
  165. package/docs/cookbook/common-patterns/webhooks.mdx +10 -6
  166. package/docs/cookbook/common-patterns/workflow-composition.mdx +30 -27
  167. package/docs/cookbook/index.mdx +22 -21
  168. package/docs/cookbook/integrations/ai-sdk.mdx +86 -48
  169. package/docs/cookbook/integrations/chat-sdk.mdx +50 -33
  170. package/docs/cookbook/integrations/sandbox.mdx +62 -45
  171. package/docs/deploying.mdx +95 -0
  172. package/docs/errors/abort-signal-timeout-in-workflow.mdx +16 -12
  173. package/docs/errors/corrupted-event-log.mdx +39 -18
  174. package/docs/errors/deployment-mismatch.mdx +71 -0
  175. package/docs/errors/fetch-in-workflow.mdx +15 -14
  176. package/docs/errors/hook-conflict.mdx +69 -13
  177. package/docs/errors/index.mdx +2 -36
  178. package/docs/errors/node-js-module-in-workflow.mdx +9 -5
  179. package/docs/errors/replay-divergence.mdx +27 -0
  180. package/docs/errors/run-expired.mdx +85 -0
  181. package/docs/errors/runtime-decryption-failed.mdx +77 -0
  182. package/docs/errors/serialization-failed.mdx +44 -12
  183. package/docs/errors/start-invalid-workflow-function.mdx +9 -5
  184. package/docs/errors/step-executed-multiple-times.mdx +23 -0
  185. package/docs/errors/step-not-registered.mdx +6 -6
  186. package/docs/errors/timeout-in-workflow.mdx +12 -8
  187. package/docs/errors/webhook-invalid-respond-with-value.mdx +18 -18
  188. package/docs/errors/webhook-response-not-sent.mdx +20 -16
  189. package/docs/errors/workflow-not-registered.mdx +5 -5
  190. package/docs/foundations/cancellation.mdx +31 -32
  191. package/docs/foundations/errors-and-retries.mdx +42 -11
  192. package/docs/foundations/hooks.mdx +64 -35
  193. package/docs/foundations/idempotency.mdx +244 -12
  194. package/docs/foundations/index.mdx +1 -23
  195. package/docs/foundations/meta.json +2 -1
  196. package/docs/foundations/serialization.mdx +21 -22
  197. package/docs/foundations/starting-workflows.mdx +106 -30
  198. package/docs/foundations/streaming.mdx +108 -60
  199. package/docs/foundations/versioning.mdx +263 -0
  200. package/docs/foundations/workflows-and-steps.mdx +9 -9
  201. package/docs/getting-started/astro.mdx +22 -18
  202. package/docs/getting-started/express.mdx +15 -11
  203. package/docs/getting-started/fastify.mdx +15 -11
  204. package/docs/getting-started/hono.mdx +15 -11
  205. package/docs/getting-started/index.mdx +10 -3
  206. package/docs/getting-started/meta.json +3 -1
  207. package/docs/getting-started/nestjs.mdx +87 -20
  208. package/docs/getting-started/next.mdx +22 -16
  209. package/docs/getting-started/nitro.mdx +22 -18
  210. package/docs/getting-started/nuxt.mdx +15 -11
  211. package/docs/getting-started/python.mdx +190 -41
  212. package/docs/getting-started/react-router/index.mdx +33 -0
  213. package/docs/getting-started/react-router/meta.json +5 -0
  214. package/docs/getting-started/react-router/v7.mdx +237 -0
  215. package/docs/getting-started/react-router/v8.mdx +232 -0
  216. package/docs/getting-started/sveltekit.mdx +20 -16
  217. package/docs/getting-started/tanstack-start.mdx +17 -13
  218. package/docs/getting-started/vite.mdx +15 -11
  219. package/docs/how-it-works/cancellation.mdx +63 -63
  220. package/docs/how-it-works/code-transform.mdx +83 -67
  221. package/docs/how-it-works/encryption.mdx +30 -26
  222. package/docs/how-it-works/event-sourcing.mdx +125 -34
  223. package/docs/how-it-works/framework-integrations.mdx +96 -337
  224. package/docs/how-it-works/understanding-directives.mdx +22 -22
  225. package/docs/internal/index.mdx +6 -4
  226. package/docs/internal/meta.json +6 -1
  227. package/docs/internal/nitro-native-build.mdx +38 -0
  228. package/docs/internal/nitro-web-ui.mdx +24 -0
  229. package/docs/internal/serializable-abort-controller.mdx +7 -7
  230. package/docs/meta.json +3 -2
  231. package/docs/observability/attributes.mdx +134 -0
  232. package/docs/observability/index.mdx +32 -10
  233. package/docs/observability/meta.json +1 -1
  234. package/docs/observability/retention.mdx +95 -0
  235. package/docs/observability/tracing.mdx +124 -0
  236. package/docs/testing/index.mdx +36 -36
  237. package/docs/testing/server-based.mdx +10 -10
  238. package/docs/whats-new.mdx +186 -0
  239. package/package.json +17 -14
  240. package/docs/api-reference/workflow-api/world/index.mdx +0 -58
  241. package/docs/api-reference/workflow-api/world/meta.json +0 -4
  242. package/docs/api-reference/workflow-api/world/observability.mdx +0 -164
  243. package/docs/api-reference/workflow-api/world/queue.mdx +0 -86
  244. package/docs/deploying/building-a-world.mdx +0 -251
  245. package/docs/deploying/index.mdx +0 -95
  246. package/docs/deploying/meta.json +0 -4
  247. package/docs/deploying/world/local-world.mdx +0 -84
  248. package/docs/deploying/world/meta.json +0 -4
  249. package/docs/deploying/world/postgres-world.mdx +0 -224
  250. package/docs/deploying/world/vercel-world.mdx +0 -179
  251. package/docs/migration-guides/index.mdx +0 -34
  252. package/docs/migration-guides/meta.json +0 -9
  253. package/docs/migration-guides/migrating-from-aws-step-functions.mdx +0 -363
  254. package/docs/migration-guides/migrating-from-inngest.mdx +0 -314
  255. package/docs/migration-guides/migrating-from-temporal.mdx +0 -318
  256. package/docs/migration-guides/migrating-from-trigger-dev.mdx +0 -337
@@ -0,0 +1,77 @@
1
+ ---
2
+ title: runtime-decryption-failed
3
+ description: The SDK's built-in AES-GCM encryption layer failed to encrypt or decrypt a workflow payload.
4
+ type: troubleshooting
5
+ summary: Resolve runtime decryption failures caused by ciphertext corruption, key mismatch, or malformed envelopes.
6
+ prerequisites:
7
+ - /docs/foundations/workflows-and-steps
8
+ related:
9
+ - /docs/foundations/errors-and-retries
10
+ ---
11
+
12
+ This error occurs when the Workflow SDK's built-in AES-GCM encryption layer fails while encrypting or decrypting a workflow payload. The SDK encrypts step inputs, step outputs, hook payloads, and other event-log data with a per-run AES-256 key whenever encryption is configured for the deployment.
13
+
14
+ This is an **internal SDK failure**: your workflow code never invokes the encryption primitives directly. When this surfaces, the ciphertext, nonce, or authentication tag the SDK tried to verify does not match the bytes that were originally produced. The run fails with the `RUNTIME_ERROR` classification.
15
+
16
+ ## Error message
17
+
18
+ ```text
19
+ AES-256-GCM decryption failed: The operation failed for an operation-specific reason
20
+ ```
21
+
22
+ The underlying cause is a native Web Crypto [`OperationError`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException#operationerror), most commonly raised by `AESCipherJob.onDone` in Node's `node:internal/crypto/util` module when the GCM authentication tag does not verify.
23
+
24
+ The thrown `RuntimeDecryptionError` carries a small `context` object with diagnostic fields to help triangulate the source:
25
+
26
+ - `operation`: `'encrypt'` or `'decrypt'`
27
+ - `byteLength`: total byte length of the payload at the failure site
28
+ - `formatPrefix`: the first 4 bytes of the input (`'encr'` for a well-formed encrypted envelope, otherwise a hex dump)
29
+
30
+ ## Why this happens
31
+
32
+ Common causes, in rough order of likelihood:
33
+
34
+ 1. **Ciphertext mutation or truncation in transit.** The encrypted payload reached the SDK with bytes that differ from what storage holds. Possible sources include a truncated HTTP response from a workflow-server ref endpoint, an edge-cache miss returning a partial 200, or a proxy drop during streaming. A truncated body whose first 4 bytes happen to still spell `encr` produces the exact "auth tag mismatch" symptom.
35
+ 2. **Key resolution mismatch.** The key used to decrypt is not the key that was used to encrypt, e.g. the run's `deploymentId` was not threaded through key resolution and the SDK fell back to the wrong deployment's key material.
36
+ 3. **Malformed encrypted envelope.** The envelope is too short to contain the GCM nonce (12 bytes) and auth tag (16 bytes), so decryption is rejected before it begins.
37
+
38
+ ## What to do
39
+
40
+ This error indicates an SDK or infrastructure problem, not a bug in your workflow code. Your workflow code does not need to change.
41
+
42
+ ### 1. Upgrade to the latest `workflow` package
43
+
44
+ The underlying issue may have already been identified and fixed:
45
+
46
+ ```bash
47
+ npm install workflow@latest
48
+ ```
49
+
50
+ ### 2. Retry the failed run
51
+
52
+ Since this is a fatal error, the run is automatically marked as `failed`. You can re-run it using the **Re-run** button in the Workflow Dashboard.
53
+
54
+ ### 3. Report the issue
55
+
56
+ If the error persists after upgrading, please [open an issue on GitHub](https://github.com/vercel/workflow/issues/new) so we can investigate. Include:
57
+
58
+ - The version of the `workflow` package you are using
59
+ - The run ID(s) of the affected workflow run(s)
60
+ - The full error message, including the `context` fields (`operation`, `byteLength`, `formatPrefix`)
61
+ - Whether the affected workflows make heavy use of large step inputs/outputs (which may indicate the failure is on the lazy-loaded ref read path)
62
+
63
+ ## This error cannot be caught
64
+
65
+ Like other `WorkflowRuntimeError` subclasses, a runtime decryption failure is **not catchable** inside your workflow function. The runtime cannot safely continue executing user code when an event-log payload can't be verified, so the entire run fails immediately and is marked as `failed`.
66
+
67
+ To handle this programmatically from outside the workflow, check the run status:
68
+
69
+ ```typescript lineNumbers
70
+ import { getRun } from "workflow/api";
71
+
72
+ const run = getRun("wrun_abc123");
73
+ const status = await run.status;
74
+ if (status === "failed") {
75
+ console.error("Run failed");
76
+ }
77
+ ```
@@ -9,11 +9,15 @@ related:
9
9
  - /docs/foundations/workflows-and-steps
10
10
  ---
11
11
 
12
+ <CopyPrompt
13
+ text="Fix Workflow serialization errors. Find the failing `start()` call, workflow argument, step return value, hook payload, or stream chunk. Replace non-serializable values such as class instances, functions, SDK clients, Response/Request objects, streams, database connections, Dates that need custom handling, Maps/Sets, or circular objects with plain JSON-compatible data, IDs, strings, numbers, booleans, arrays, and objects. Recreate runtime-only clients or objects inside `&quot;use step&quot;` helpers instead of passing them through the workflow log. For external resources, pass a stable ID or URL and load the resource inside the step. Add a test or local route call that serializes the same input/output path successfully."
14
+ />
15
+
12
16
  This error occurs when you try to pass non-serializable data between execution boundaries in your workflow. All data passed between workflow functions, step functions, and the workflow runtime must be serializable to persist in the event log.
13
17
 
14
- ## Error Message
18
+ ## Error message
15
19
 
16
- ```
20
+ ```text
17
21
  Failed to serialize workflow arguments. Ensure you're passing serializable types
18
22
  (plain objects, arrays, primitives, Date, RegExp, Map, Set).
19
23
  ```
@@ -25,7 +29,35 @@ This error can appear when:
25
29
  - Serializing step arguments
26
30
  - Serializing step return values
27
31
 
28
- ## Why This Happens
32
+ ## Where the error surfaces
33
+
34
+ Where you observe the failure depends on which boundary it crosses:
35
+
36
+ - **Workflow arguments**: `start()` throws synchronously in your application code.
37
+ - **Step arguments and step return values**: the *step* fails with the `SerializationError`, exactly like a step whose body threw a fatal error: no retries (the failure is deterministic), and a `try/catch` around the step call in your workflow code observes it. The step's recorded input shows `[input unavailable: step argument serialization failed]` when the arguments were the unserializable part.
38
+ - **Workflow return values**: the workflow body has already returned, so nothing can catch it; the run fails.
39
+
40
+ ```typescript lineNumbers
41
+ async function stepWithBadArguments(value: unknown) {
42
+ "use step";
43
+ return value;
44
+ }
45
+
46
+ export async function processWorkflow(someValue: unknown) {
47
+ "use workflow";
48
+
49
+ try {
50
+ await stepWithBadArguments(someValue);
51
+ } catch (err) {
52
+ // err.name === "SerializationError"
53
+ // "Failed to serialize step arguments at path ..."
54
+ }
55
+ }
56
+ ```
57
+
58
+ Uncaught, the error propagates out of the workflow body and the run fails immediately with the error code `USER_ERROR`; it does not retry.
59
+
60
+ ## Why this happens
29
61
 
30
62
  Workflows persist their state using an event log. Every value that crosses execution boundaries must be:
31
63
 
@@ -34,9 +66,9 @@ Workflows persist their state using an event log. Every value that crosses execu
34
66
 
35
67
  Functions, class instances, symbols, and other non-serializable types cannot be properly reconstructed after serialization, which would break workflow replay.
36
68
 
37
- ## Common Causes
69
+ ## Common causes
38
70
 
39
- ### Passing Functions
71
+ ### Passing functions
40
72
 
41
73
  {/* @skip-typecheck: incomplete code sample */}
42
74
  ```typescript lineNumbers
@@ -68,7 +100,7 @@ async function processStep(config: { shouldLog: boolean }) {
68
100
  }
69
101
  ```
70
102
 
71
- ### Class Instances
103
+ ### Class instances
72
104
 
73
105
  ```typescript lineNumbers
74
106
  class User {
@@ -107,11 +139,11 @@ async function greetStep(userData: { name: string }) {
107
139
  }
108
140
  ```
109
141
 
110
- ## Supported Serializable Types
142
+ ## Supported serializable types
111
143
 
112
144
  Workflow SDK supports these types across execution boundaries:
113
145
 
114
- ### Standard JSON Types
146
+ ### Standard JSON types
115
147
 
116
148
  - `string`, `number`, `boolean`, `null`
117
149
  - Arrays of serializable values
@@ -119,10 +151,10 @@ Workflow SDK supports these types across execution boundaries:
119
151
 
120
152
  To learn more about supported types, see the [Serialization](/docs/foundations/serialization) section.
121
153
 
122
- ## Debugging Serialization Issues
154
+ ## Debugging serialization issues
123
155
 
124
156
  To identify what's causing serialization to fail:
125
157
 
126
- 1. **Check the error stack trace** - it often shows which property failed
127
- 2. **Simplify your data** - temporarily pass smaller objects to isolate the issue
128
- 3. **Ensure you are using supported data types** - see the [Serialization](/docs/foundations/serialization) section for more details
158
+ 1. **Check the error stack trace**: It often shows which property failed.
159
+ 2. **Simplify your data**: Temporarily pass smaller objects to isolate the issue.
160
+ 3. **Use supported data types**: See [Serialization](/docs/foundations/serialization) for details.
@@ -11,19 +11,23 @@ related:
11
11
  - /docs/api-reference/workflow-next/with-workflow
12
12
  ---
13
13
 
14
+ <CopyPrompt
15
+ text="Fix `start()` receiving an invalid workflow function. Find the function passed to `start()` from `workflow/api`. Ensure the target function is directly imported, exported from its workflow file, and contains the literal `&quot;use workflow&quot;` directive at the top of the function body. Do not pass wrapper callbacks like `start(async () => workflowFn())`; call `start(workflowFn, [args])`. Verify the framework integration is configured (`withWorkflow()` in Next.js, `workflow()`/`workflowPlugin()` in Vite/Astro/SvelteKit, `workflow/nitro`, `workflow/nuxt`, or `@workflow/nest` as appropriate) and that the workflow file is inside a transformed directory. Add a local route/test that calls `start(workflowFn, args)` and confirms a run is created."
16
+ />
17
+
14
18
  This error occurs when `start()` receives a function that does not have Workflow SDK's generated workflow metadata. In practice, that usually means the function is missing `"use workflow"` or the file was never transformed by your framework integration.
15
19
 
16
- ## Error Message
20
+ ## Error message
17
21
 
18
- ```
22
+ ```text
19
23
  'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.
20
24
  ```
21
25
 
22
- ## Why This Happens
26
+ ## Why this happens
23
27
 
24
- `start()` expects an imported workflow function, not just any async function. During compilation, Workflow SDK transforms files that contain `"use workflow"` and attaches generated metadata such as the workflow ID. If that transform never runs, or if you pass a wrapper function instead of the transformed export, `start()` cannot identify what to enqueue and throws this error.
28
+ `start()` expects an imported workflow function rather than any async function. During compilation, Workflow SDK transforms files that contain `"use workflow"` and attaches generated metadata such as the workflow ID. If that transform never runs, or if you pass a wrapper function instead of the transformed export, `start()` cannot identify what to enqueue and throws this error.
25
29
 
26
- ## Common Causes
30
+ ## Common causes
27
31
 
28
32
  ### Missing `"use workflow"`
29
33
 
@@ -0,0 +1,23 @@
1
+ ---
2
+ title: Step executed multiple times
3
+ description: A step ran more than once because its function invocation crashed before it could report a result.
4
+ type: troubleshooting
5
+ summary: Diagnose duplicate step_started events caused by function timeouts, OOMs, or network issues.
6
+ prerequisites:
7
+ - /docs/foundations/workflows-and-steps
8
+ related:
9
+ - /docs/observability
10
+ - /docs/foundations/errors-and-retries
11
+ ---
12
+
13
+ There may be cases where you see multiple `step_started` events for the same step in a workflow run. This happens if the function invocation executing the step crashes unexpectedly, and the step can not report the error. The step will be re-tried according to your retry policy in this case, but no error will be visible in the [Observability UI](/docs/observability).
14
+
15
+ ## Common causes
16
+
17
+ - **Function timeouts**: if your step code runs longer than the configured maximum function duration, it will be killed. Compare the gap between the `step_started` events to your configured function duration to be sure.
18
+ - **Out of memory (OOM)**: if your step code loads enough data into memory, especially if the step is invoked concurrently, the function invocation might run out of memory. You can see your function's peak memory use by going to the [Observability Query page](https://vercel.com/docs/observability) and showing the **Function Invocation Peak Memory** metric, then filtering down the **Route** to `/.well-known/workflow` endpoints.
19
+ - **Network issues**: persistent firewall, network stability, and related issues might prevent your function from reporting results or errors. This should be temporary.
20
+
21
+ ## Getting help
22
+
23
+ If you consistently see multiple `step_started` events and have ruled out function timeouts, OOMs, and firewall issues, please [contact support](https://vercel.com/help).
@@ -4,7 +4,7 @@ description: A step function is not registered in the current deployment.
4
4
  type: troubleshooting
5
5
  summary: Resolve step not registered errors caused by build issues.
6
6
  prerequisites:
7
- - /docs/foundations/steps
7
+ - /docs/foundations/workflows-and-steps
8
8
  related:
9
9
  - /docs/errors/workflow-not-registered
10
10
  - /docs/api-reference/workflow-errors/step-not-registered-error
@@ -12,21 +12,21 @@ related:
12
12
 
13
13
  This error occurs when the Workflow runtime tries to execute a step function that is not registered in the current deployment. When this happens, the step fails (like a `FatalError`) and control is passed back to the workflow function, which can optionally handle the failure.
14
14
 
15
- ## Error Message
15
+ ## Error message
16
16
 
17
- ```
17
+ ```text
18
18
  Step "<stepName>" is not registered in the current deployment.
19
19
  This usually indicates a build or bundling issue that caused the step
20
20
  to not be included in the deployment.
21
21
  ```
22
22
 
23
- ## Why This Happens
23
+ ## Why this happens
24
24
 
25
25
  Workflow runs are pegged to a specific deployment, so this error is not caused by newer deployments overriding the running code. Instead, it means the step function was not included in the deployment's workflow bundle at build time.
26
26
 
27
27
  This is an **infrastructure error**, not a user code error.
28
28
 
29
- ## Common Causes
29
+ ## Common causes
30
30
 
31
31
  ### Build tooling issue
32
32
 
@@ -40,7 +40,7 @@ Something went wrong during the build process that caused the step function to n
40
40
 
41
41
  The step function was deleted or its `"use step"` directive was removed, but the workflow still references it. Ensure all steps referenced by your workflow are present in the codebase.
42
42
 
43
- ## How to Resolve
43
+ ## How to resolve
44
44
 
45
45
  1. **Check your build logs:** Look for errors or warnings related to workflow bundling. Ensure the step file contains a valid `"use step"` directive and is properly exported.
46
46
 
@@ -9,21 +9,25 @@ related:
9
9
  - /docs/api-reference/workflow/sleep
10
10
  ---
11
11
 
12
+ <CopyPrompt
13
+ text="Fix timer usage inside workflow functions. Search `&quot;use workflow&quot;` functions for `setTimeout`, `setInterval`, `timers/promises`, polling loops, or `AbortSignal.timeout()`. Replace workflow delays with `await sleep(&quot;5s&quot;)`, `await sleep(&quot;24h&quot;)`, or `await sleep(date)` from `workflow`. For polling, use a workflow loop that calls a `&quot;use step&quot;` helper to check external state and then `await sleep(...)` between attempts. If a step itself needs a short in-process delay, keep that timer inside the `&quot;use step&quot;` function only. Verify the workflow can replay and resume after the durable sleep."
14
+ />
15
+
12
16
  This error occurs when you try to use `setTimeout()`, `setInterval()`, or related timing functions directly inside a workflow function.
13
17
 
14
- ## Error Message
18
+ ## Error message
15
19
 
16
- ```
20
+ ```text
17
21
  Timeout functions like "setTimeout" and "setInterval" are not supported in workflow functions. Use the "sleep" function from "workflow" for time-based delays.
18
22
  ```
19
23
 
20
- ## Why This Happens
24
+ ## Why this happens
21
25
 
22
26
  Workflow functions run in a sandboxed environment where timing functions like `setTimeout()` and `setInterval()` are not available. These functions rely on asynchronous scheduling that would break the **deterministic replay** guarantees that workflows depend on.
23
27
 
24
28
  When a workflow suspends and later resumes, it replays from the event log. If timing functions were allowed, the replay would produce different results than the original execution.
25
29
 
26
- ## Quick Fix
30
+ ## Quick fix
27
31
 
28
32
  Use the `sleep` function from the `workflow` package for time-based delays. Unlike `setTimeout()`, `sleep` is tracked in the event log and replays correctly.
29
33
 
@@ -55,7 +59,7 @@ export async function delayedWorkflow() {
55
59
  }
56
60
  ```
57
61
 
58
- ## Unavailable Functions
62
+ ## Unavailable functions
59
63
 
60
64
  These timing functions cannot be used in workflow functions:
61
65
 
@@ -66,9 +70,9 @@ These timing functions cannot be used in workflow functions:
66
70
  - `clearInterval()`
67
71
  - `clearImmediate()`
68
72
 
69
- ## Common Scenarios
73
+ ## Common scenarios
70
74
 
71
- ### Polling with Delays
75
+ ### Polling with delays
72
76
 
73
77
  If you need to poll an external service with delays between requests:
74
78
 
@@ -98,7 +102,7 @@ async function checkStatus() {
98
102
  }
99
103
  ```
100
104
 
101
- ### Scheduled Delays
105
+ ### Scheduled delays
102
106
 
103
107
  For workflows that need to wait for a specific duration:
104
108
 
@@ -11,13 +11,13 @@ related:
11
11
 
12
12
  This error occurs when you provide an invalid value for the `respondWith` option when creating a webhook. The `respondWith` option must be either `"manual"` or a `Response` object.
13
13
 
14
- ## Error Message
14
+ ## Error message
15
15
 
16
- ```
16
+ ```text
17
17
  Invalid `respondWith` value: [value]
18
18
  ```
19
19
 
20
- ## Why This Happens
20
+ ## Why this happens
21
21
 
22
22
  When creating a webhook with `createWebhook()`, you can specify how the webhook should respond to incoming HTTP requests using the `respondWith` option. This option only accepts specific values:
23
23
 
@@ -25,16 +25,16 @@ When creating a webhook with `createWebhook()`, you can specify how the webhook
25
25
  2. A `Response` object - A pre-defined response to send immediately
26
26
  3. `undefined` (default) - Returns a `202 Accepted` response
27
27
 
28
- ## Common Causes
28
+ ## Common causes
29
29
 
30
- ### Using an Invalid String Value
30
+ ### Using an invalid string value
31
31
 
32
32
  ```typescript lineNumbers
33
33
  // Error - invalid string value
34
34
  export async function webhookWorkflow() {
35
35
  "use workflow";
36
36
 
37
- const webhook = await createWebhook({
37
+ const webhook = createWebhook({
38
38
  respondWith: "automatic", // Error! // [!code highlight]
39
39
  });
40
40
  }
@@ -49,7 +49,7 @@ import { createWebhook } from "workflow";
49
49
  export async function webhookWorkflow() {
50
50
  "use workflow";
51
51
 
52
- const webhook = await createWebhook({
52
+ const webhook = createWebhook({
53
53
  respondWith: "manual", // [!code highlight]
54
54
  });
55
55
 
@@ -60,14 +60,14 @@ export async function webhookWorkflow() {
60
60
  }
61
61
  ```
62
62
 
63
- ### Using a Non-Response Object
63
+ ### Using a non-Response object
64
64
 
65
65
  ```typescript lineNumbers
66
66
  // Error - plain object instead of Response
67
67
  export async function webhookWorkflow() {
68
68
  "use workflow";
69
69
 
70
- const webhook = await createWebhook({
70
+ const webhook = createWebhook({
71
71
  respondWith: { status: 200, body: "OK" }, // Error! // [!code highlight]
72
72
  });
73
73
  }
@@ -82,32 +82,32 @@ import { createWebhook } from "workflow";
82
82
  export async function webhookWorkflow() {
83
83
  "use workflow";
84
84
 
85
- const webhook = await createWebhook({
85
+ const webhook = createWebhook({
86
86
  respondWith: new Response("OK", { status: 200 }), // [!code highlight]
87
87
  });
88
88
  }
89
89
  ```
90
90
 
91
- ## Valid Usage Examples
91
+ ## Valid usage examples
92
92
 
93
- ### Default Behavior (202 Response)
93
+ ### Default behavior (202 response)
94
94
 
95
95
  ```typescript lineNumbers
96
96
  import { createWebhook } from "workflow";
97
97
 
98
98
  // Returns 202 Accepted automatically
99
- const webhook = await createWebhook();
99
+ const webhook = createWebhook();
100
100
  const request = await webhook;
101
101
  // No need to send a response
102
102
  ```
103
103
 
104
- ### Manual Response
104
+ ### Manual response
105
105
 
106
106
  ```typescript lineNumbers
107
107
  import { createWebhook } from "workflow";
108
108
 
109
109
  // Manual response control
110
- const webhook = await createWebhook({
110
+ const webhook = createWebhook({
111
111
  respondWith: "manual",
112
112
  });
113
113
 
@@ -125,13 +125,13 @@ await request.respondWith(
125
125
  );
126
126
  ```
127
127
 
128
- ### Pre-defined Response
128
+ ### Pre-defined response
129
129
 
130
130
  ```typescript lineNumbers
131
131
  import { createWebhook } from "workflow";
132
132
 
133
133
  // Immediate response
134
- const webhook = await createWebhook({
134
+ const webhook = createWebhook({
135
135
  respondWith: new Response("Request received", { status: 200 }),
136
136
  });
137
137
 
@@ -139,7 +139,7 @@ const request = await webhook;
139
139
  // Response already sent
140
140
  ```
141
141
 
142
- ## Learn More
142
+ ## Learn more
143
143
 
144
144
  - [createWebhook() API Reference](/docs/api-reference/workflow/create-webhook)
145
145
  - [resumeWebhook() API Reference](/docs/api-reference/workflow-api/resume-webhook)
@@ -9,30 +9,34 @@ related:
9
9
  - /docs/api-reference/workflow/create-webhook
10
10
  ---
11
11
 
12
+ <CopyPrompt
13
+ text="Fix webhook-response-not-sent errors. Find `createWebhook({ respondWith: &quot;manual&quot; })` usage. In the workflow, await the webhook request and pass the `RequestWithResponse` into a `&quot;use step&quot;` helper for validation and side effects. In every success, validation failure, catch, and early-return branch, call `await request.respondWith(new Response(...))` or `await request.respondWith(Response.json(...))` exactly once before the webhook completes. If manual control is not needed, remove `respondWith: &quot;manual&quot;` or use a static `Response` option. Add tests or local webhook calls for success, invalid input, and thrown-error paths."
14
+ />
15
+
12
16
  This error occurs when a webhook is configured with `respondWith: "manual"` but the workflow does not send a response using `request.respondWith()` before the webhook execution completes.
13
17
 
14
- ## Error Message
18
+ ## Error message
15
19
 
16
- ```
20
+ ```text
17
21
  Workflow run did not send a response
18
22
  ```
19
23
 
20
- ## Why This Happens
24
+ ## Why this happens
21
25
 
22
26
  When you create a webhook with `respondWith: "manual"`, you are responsible for calling `request.respondWith()` to send the HTTP response back to the caller. If the workflow execution completes without sending a response, this error will be thrown.
23
27
 
24
28
  The webhook infrastructure waits for a response to be sent, and if none is provided, it cannot complete the HTTP request properly.
25
29
 
26
- ## Common Causes
30
+ ## Common causes
27
31
 
28
- ### Forgetting to Call `request.respondWith()`
32
+ ### Forgetting to call `request.respondWith()`
29
33
 
30
34
  ```typescript lineNumbers
31
35
  // Error - no response sent
32
36
  export async function webhookWorkflow() {
33
37
  "use workflow";
34
38
 
35
- const webhook = await createWebhook({
39
+ const webhook = createWebhook({
36
40
  respondWith: "manual",
37
41
  });
38
42
 
@@ -55,7 +59,7 @@ import { createWebhook } from "workflow";
55
59
  export async function webhookWorkflow() {
56
60
  "use workflow";
57
61
 
58
- const webhook = await createWebhook({
62
+ const webhook = createWebhook({
59
63
  respondWith: "manual",
60
64
  });
61
65
 
@@ -70,14 +74,14 @@ export async function webhookWorkflow() {
70
74
  }
71
75
  ```
72
76
 
73
- ### Conditional Response Logic
77
+ ### Conditional response logic
74
78
 
75
79
  ```typescript lineNumbers
76
80
  // Error - response only sent in some branches
77
81
  export async function webhookWorkflow() {
78
82
  "use workflow";
79
83
 
80
- const webhook = await createWebhook({
84
+ const webhook = createWebhook({
81
85
  respondWith: "manual",
82
86
  });
83
87
 
@@ -100,7 +104,7 @@ import { createWebhook } from "workflow";
100
104
  export async function webhookWorkflow() {
101
105
  "use workflow";
102
106
 
103
- const webhook = await createWebhook({
107
+ const webhook = createWebhook({
104
108
  respondWith: "manual",
105
109
  });
106
110
 
@@ -115,14 +119,14 @@ export async function webhookWorkflow() {
115
119
  }
116
120
  ```
117
121
 
118
- ### Exception Before Response
122
+ ### Exception before response
119
123
 
120
124
  ```typescript lineNumbers
121
125
  // Error - exception thrown before response
122
126
  export async function webhookWorkflow() {
123
127
  "use workflow";
124
128
 
125
- const webhook = await createWebhook({
129
+ const webhook = createWebhook({
126
130
  respondWith: "manual",
127
131
  });
128
132
 
@@ -145,7 +149,7 @@ import { createWebhook } from "workflow";
145
149
  export async function webhookWorkflow() {
146
150
  "use workflow";
147
151
 
148
- const webhook = await createWebhook({
152
+ const webhook = createWebhook({
149
153
  respondWith: "manual",
150
154
  });
151
155
 
@@ -164,7 +168,7 @@ export async function webhookWorkflow() {
164
168
  }
165
169
  ```
166
170
 
167
- ## Alternative: Use Default Response Mode
171
+ ## Alternative: Use default response mode
168
172
 
169
173
  If you don't need custom response control, consider using the default response mode which automatically returns a `202 Accepted` response:
170
174
 
@@ -175,7 +179,7 @@ import { createWebhook } from "workflow";
175
179
  export async function webhookWorkflow() {
176
180
  "use workflow";
177
181
 
178
- const webhook = await createWebhook(); // [!code highlight]
182
+ const webhook = createWebhook(); // [!code highlight]
179
183
  const request = await webhook;
180
184
 
181
185
  // Process request asynchronously
@@ -185,7 +189,7 @@ export async function webhookWorkflow() {
185
189
  }
186
190
  ```
187
191
 
188
- ## Learn More
192
+ ## Learn more
189
193
 
190
194
  - [createWebhook() API Reference](/docs/api-reference/workflow/create-webhook)
191
195
  - [resumeWebhook() API Reference](/docs/api-reference/workflow-api/resume-webhook)
@@ -12,19 +12,19 @@ related:
12
12
 
13
13
  This error occurs when the Workflow runtime tries to execute a workflow function that is not registered in the current deployment. When this happens, the run fails with a `RUNTIME_ERROR` error code.
14
14
 
15
- ## Error Message
15
+ ## Error message
16
16
 
17
- ```
17
+ ```text
18
18
  Workflow "<workflowName>" is not registered in the current deployment.
19
19
  This usually means a run was started against a deployment that does not
20
20
  have this workflow, or there was a build/bundling issue.
21
21
  ```
22
22
 
23
- ## Why This Happens
23
+ ## Why this happens
24
24
 
25
25
  This error means the deployment that received the workflow execution request does not have the specified workflow function in its bundle. This is an **infrastructure error**, not a user code error.
26
26
 
27
- ## Common Causes
27
+ ## Common causes
28
28
 
29
29
  ### Run started against a deployment without the workflow
30
30
 
@@ -57,7 +57,7 @@ Something went wrong during the build process that caused the workflow function
57
57
  - The workflow function is not exported from the workflow file
58
58
  - An esbuild or SWC plugin error silently excluded the workflow
59
59
 
60
- ## How to Resolve
60
+ ## How to resolve
61
61
 
62
62
  1. **If the workflow was renamed or moved:** Deploy with the workflow restored to its original name and location, then retry the run. Alternatively, start a new run using the updated workflow name against the current deployment.
63
63