workflow 5.0.0-beta.9 → 5.0.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 (263) hide show
  1. package/README.md +68 -23
  2. package/dist/api-workflow.d.ts +3 -1
  3. package/dist/api-workflow.d.ts.map +1 -1
  4. package/dist/api-workflow.js +2 -1
  5. package/dist/api.d.ts +5 -4
  6. package/dist/api.d.ts.map +1 -1
  7. package/dist/api.js +6 -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 +4 -4
  12. package/dist/internal/builtins.js +6 -6
  13. package/dist/internal/errors.d.ts +1 -1
  14. package/dist/internal/errors.d.ts.map +1 -1
  15. package/dist/internal/errors.js +2 -2
  16. package/dist/nest-builder.d.ts +2 -0
  17. package/dist/nest-builder.d.ts.map +1 -0
  18. package/dist/nest-builder.js +2 -0
  19. package/dist/nest-vercel-builder.d.ts +2 -0
  20. package/dist/nest-vercel-builder.d.ts.map +1 -0
  21. package/dist/nest-vercel-builder.js +2 -0
  22. package/dist/runtime.d.ts +2 -1
  23. package/dist/runtime.d.ts.map +1 -1
  24. package/dist/runtime.js +4 -1
  25. package/docs/advanced/dynamic-workflows.mdx +224 -0
  26. package/docs/ai/chat-session-modeling.mdx +176 -422
  27. package/docs/ai/defining-tools.mdx +6 -7
  28. package/docs/ai/human-in-the-loop.mdx +11 -11
  29. package/docs/ai/index.mdx +67 -72
  30. package/docs/ai/message-queueing.mdx +71 -110
  31. package/docs/ai/meta.json +1 -0
  32. package/docs/ai/resumable-streams.mdx +40 -28
  33. package/docs/ai/sleep-and-delays.mdx +10 -10
  34. package/docs/ai/streaming-updates-from-tools.mdx +6 -6
  35. package/docs/api-reference/index.mdx +25 -1
  36. package/docs/api-reference/meta.json +8 -0
  37. package/docs/api-reference/vitest/index.mdx +68 -15
  38. package/docs/api-reference/workflow/create-hook.mdx +166 -10
  39. package/docs/api-reference/workflow/create-webhook.mdx +16 -15
  40. package/docs/api-reference/workflow/define-hook.mdx +37 -33
  41. package/docs/api-reference/workflow/fatal-error.mdx +30 -8
  42. package/docs/api-reference/workflow/fetch.mdx +14 -10
  43. package/docs/api-reference/workflow/get-step-metadata.mdx +2 -2
  44. package/docs/api-reference/workflow/get-workflow-metadata.mdx +3 -3
  45. package/docs/api-reference/workflow/get-writable.mdx +7 -7
  46. package/docs/api-reference/workflow/index.mdx +3 -3
  47. package/docs/api-reference/workflow/retryable-error.mdx +1 -1
  48. package/docs/api-reference/workflow/set-attributes.mdx +63 -0
  49. package/docs/api-reference/workflow/sleep.mdx +4 -4
  50. package/docs/api-reference/workflow-ai/durable-agent.mdx +63 -101
  51. package/docs/api-reference/workflow-ai/index.mdx +5 -5
  52. package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +67 -24
  53. package/docs/api-reference/workflow-api/get-hook-by-token.mdx +28 -12
  54. package/docs/api-reference/workflow-api/get-run.mdx +43 -8
  55. package/docs/api-reference/workflow-api/index.mdx +8 -9
  56. package/docs/api-reference/workflow-api/register-lifecycle-hooks.mdx +87 -0
  57. package/docs/api-reference/workflow-api/resume-hook.mdx +73 -12
  58. package/docs/api-reference/workflow-api/resume-webhook.mdx +11 -9
  59. package/docs/api-reference/workflow-api/start.mdx +107 -12
  60. package/docs/api-reference/workflow-astro/index.mdx +18 -0
  61. package/docs/api-reference/workflow-astro/meta.json +4 -0
  62. package/docs/api-reference/workflow-astro/workflow.mdx +45 -0
  63. package/docs/api-reference/workflow-errors/entity-conflict-error.mdx +4 -4
  64. package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +60 -0
  65. package/docs/api-reference/workflow-errors/hook-force-claimed-error.mdx +70 -0
  66. package/docs/api-reference/workflow-errors/hook-not-found-error.mdx +8 -8
  67. package/docs/api-reference/workflow-errors/index.mdx +91 -0
  68. package/docs/api-reference/workflow-errors/meta.json +7 -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 +13 -6
  78. package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +12 -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 +15 -11
  84. package/docs/api-reference/workflow-nest/configure-workflow-controller.mdx +37 -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 +46 -0
  89. package/docs/api-reference/workflow-nest/workflow-module.mdx +134 -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 +51 -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 +104 -35
  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 +53 -41
  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 +79 -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 +399 -0
  149. package/docs/configuration/worlds.mdx +315 -0
  150. package/docs/cookbook/advanced/child-workflows.mdx +33 -25
  151. package/docs/cookbook/advanced/publishing-libraries.mdx +65 -56
  152. package/docs/cookbook/advanced/serializable-steps.mdx +48 -68
  153. package/docs/cookbook/advanced/upgrading-workflows.mdx +35 -31
  154. package/docs/cookbook/agent-patterns/agent-cancellation.mdx +78 -60
  155. package/docs/cookbook/agent-patterns/durable-agent.mdx +23 -135
  156. package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +180 -195
  157. package/docs/cookbook/common-patterns/batching.mdx +20 -14
  158. package/docs/cookbook/common-patterns/idempotency.mdx +41 -53
  159. package/docs/cookbook/common-patterns/rate-limiting.mdx +8 -4
  160. package/docs/cookbook/common-patterns/saga.mdx +23 -19
  161. package/docs/cookbook/common-patterns/scheduling.mdx +30 -22
  162. package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +29 -25
  163. package/docs/cookbook/common-patterns/timeouts.mdx +26 -21
  164. package/docs/cookbook/common-patterns/webhooks.mdx +10 -6
  165. package/docs/cookbook/common-patterns/workflow-composition.mdx +27 -17
  166. package/docs/cookbook/index.mdx +22 -22
  167. package/docs/cookbook/integrations/ai-sdk.mdx +63 -48
  168. package/docs/cookbook/integrations/chat-sdk.mdx +46 -33
  169. package/docs/cookbook/integrations/sandbox.mdx +58 -45
  170. package/docs/deploying.mdx +106 -0
  171. package/docs/errors/abort-signal-timeout-in-workflow.mdx +16 -12
  172. package/docs/errors/corrupted-event-log.mdx +39 -18
  173. package/docs/errors/deployment-mismatch.mdx +71 -0
  174. package/docs/errors/fetch-in-workflow.mdx +15 -14
  175. package/docs/errors/hook-conflict.mdx +38 -11
  176. package/docs/errors/hook-force-claimed.mdx +96 -0
  177. package/docs/errors/index.mdx +24 -37
  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 +54 -11
  192. package/docs/foundations/hooks.mdx +98 -35
  193. package/docs/foundations/idempotency.mdx +267 -12
  194. package/docs/foundations/index.mdx +1 -26
  195. package/docs/foundations/serialization.mdx +22 -22
  196. package/docs/foundations/starting-workflows.mdx +104 -30
  197. package/docs/foundations/streaming.mdx +108 -60
  198. package/docs/foundations/versioning.mdx +4 -4
  199. package/docs/foundations/workflows-and-steps.mdx +9 -9
  200. package/docs/getting-started/astro.mdx +22 -18
  201. package/docs/getting-started/express.mdx +15 -11
  202. package/docs/getting-started/fastify.mdx +15 -11
  203. package/docs/getting-started/hono.mdx +15 -11
  204. package/docs/getting-started/index.mdx +10 -3
  205. package/docs/getting-started/meta.json +3 -1
  206. package/docs/getting-started/nestjs.mdx +264 -21
  207. package/docs/getting-started/next.mdx +18 -14
  208. package/docs/getting-started/nitro.mdx +22 -18
  209. package/docs/getting-started/nuxt.mdx +15 -11
  210. package/docs/getting-started/python.mdx +190 -41
  211. package/docs/getting-started/react-router/index.mdx +33 -0
  212. package/docs/getting-started/react-router/meta.json +5 -0
  213. package/docs/getting-started/react-router/v7.mdx +237 -0
  214. package/docs/getting-started/react-router/v8.mdx +232 -0
  215. package/docs/getting-started/sveltekit.mdx +20 -16
  216. package/docs/getting-started/tanstack-start.mdx +17 -13
  217. package/docs/getting-started/vite.mdx +15 -11
  218. package/docs/how-it-works/cancellation.mdx +63 -63
  219. package/docs/how-it-works/code-transform.mdx +82 -66
  220. package/docs/how-it-works/encryption.mdx +30 -26
  221. package/docs/how-it-works/event-sourcing.mdx +132 -35
  222. package/docs/how-it-works/framework-integrations.mdx +96 -337
  223. package/docs/how-it-works/understanding-directives.mdx +22 -22
  224. package/docs/internal/index.mdx +6 -4
  225. package/docs/internal/meta.json +6 -1
  226. package/docs/internal/nitro-native-build.mdx +38 -0
  227. package/docs/internal/nitro-web-ui.mdx +24 -0
  228. package/docs/internal/serializable-abort-controller.mdx +7 -7
  229. package/docs/meta.json +4 -2
  230. package/docs/observability/attributes.mdx +91 -21
  231. package/docs/observability/index.mdx +29 -15
  232. package/docs/observability/lifecycle-hooks.mdx +95 -0
  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 +120 -38
  237. package/docs/testing/server-based.mdx +10 -10
  238. package/docs/whats-new.mdx +190 -0
  239. package/docs/worlds/building-a-world.mdx +538 -0
  240. package/docs/worlds/local.mdx +129 -0
  241. package/docs/worlds/meta.json +10 -0
  242. package/docs/worlds/postgres.mdx +424 -0
  243. package/docs/worlds/upgrading-to-v5.mdx +162 -0
  244. package/docs/worlds/vercel.mdx +345 -0
  245. package/package.json +17 -14
  246. package/docs/api-reference/workflow/experimental-set-attributes.mdx +0 -63
  247. package/docs/api-reference/workflow-api/world/index.mdx +0 -58
  248. package/docs/api-reference/workflow-api/world/meta.json +0 -4
  249. package/docs/api-reference/workflow-api/world/observability.mdx +0 -164
  250. package/docs/api-reference/workflow-api/world/queue.mdx +0 -86
  251. package/docs/deploying/building-a-world.mdx +0 -251
  252. package/docs/deploying/index.mdx +0 -95
  253. package/docs/deploying/meta.json +0 -4
  254. package/docs/deploying/world/local-world.mdx +0 -84
  255. package/docs/deploying/world/meta.json +0 -4
  256. package/docs/deploying/world/postgres-world.mdx +0 -224
  257. package/docs/deploying/world/vercel-world.mdx +0 -181
  258. package/docs/migration-guides/index.mdx +0 -34
  259. package/docs/migration-guides/meta.json +0 -9
  260. package/docs/migration-guides/migrating-from-aws-step-functions.mdx +0 -358
  261. package/docs/migration-guides/migrating-from-inngest.mdx +0 -304
  262. package/docs/migration-guides/migrating-from-temporal.mdx +0 -313
  263. package/docs/migration-guides/migrating-from-trigger-dev.mdx +0 -328
@@ -29,7 +29,7 @@ try {
29
29
  }
30
30
  ```
31
31
 
32
- ## API Signature
32
+ ## API signature
33
33
 
34
34
  ### Properties
35
35
 
@@ -42,7 +42,7 @@ interface RunExpiredError {
42
42
  export default RunExpiredError;`}
43
43
  />
44
44
 
45
- ### Static Methods
45
+ ### Static methods
46
46
 
47
47
  #### `RunExpiredError.is(value)`
48
48
 
@@ -0,0 +1,58 @@
1
+ ---
2
+ title: RunNotSupportedError
3
+ description: Thrown when a workflow run requires a newer workflow spec version than the installed SDK supports.
4
+ type: reference
5
+ summary: Catch RunNotSupportedError when stored run data requires a newer workflow package version.
6
+ related:
7
+ - /docs/foundations/versioning
8
+ ---
9
+
10
+ `RunNotSupportedError` is thrown when reading a workflow run whose data was written with a newer workflow spec version than the running SDK supports. This typically means the run was created by a newer version of the `workflow` package. Upgrade the package to process it.
11
+
12
+ ```typescript lineNumbers
13
+ import { RunNotSupportedError } from "workflow/errors"
14
+ declare function readRun(runId: string): Promise<unknown>; // @setup
15
+ declare const runId: string; // @setup
16
+
17
+ try {
18
+ await readRun(runId);
19
+ } catch (error) {
20
+ if (RunNotSupportedError.is(error)) { // [!code highlight]
21
+ console.error(
22
+ `Run requires spec v${error.runSpecVersion}, world supports v${error.worldSpecVersion}`
23
+ );
24
+ }
25
+ }
26
+ ```
27
+
28
+ ## API signature
29
+
30
+ ### Properties
31
+
32
+ <TSDoc
33
+ definition={`
34
+ interface RunNotSupportedError {
35
+ /** The spec version the run's stored data requires. */
36
+ runSpecVersion: number;
37
+ /** The spec version the current World supports. */
38
+ worldSpecVersion: number;
39
+ /** The error message. */
40
+ message: string;
41
+ }
42
+ export default RunNotSupportedError;`}
43
+ />
44
+
45
+ ### Static methods
46
+
47
+ #### `RunNotSupportedError.is(value)`
48
+
49
+ Type-safe check for `RunNotSupportedError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
50
+
51
+ ```typescript
52
+ import { RunNotSupportedError } from "workflow/errors"
53
+ declare const error: unknown; // @setup
54
+
55
+ if (RunNotSupportedError.is(error)) {
56
+ // error is typed as RunNotSupportedError
57
+ }
58
+ ```
@@ -8,7 +8,7 @@ related:
8
8
  - /docs/api-reference/workflow-errors/workflow-not-registered-error
9
9
  ---
10
10
 
11
- `StepNotRegisteredError` is thrown when the runtime tries to execute a step function that is not registered in the current deployment. This is an infrastructure error — not a user code error. It typically indicates a build or bundling issue that caused the step to not be included in the deployment.
11
+ `StepNotRegisteredError` is thrown when the runtime tries to execute a step function that is not registered in the current deployment. This is an infrastructure error, not a user code error. It typically indicates a build or bundling issue that caused the step to not be included in the deployment.
12
12
 
13
13
  When this error occurs, the step fails (like a `FatalError`) and control is passed back to the workflow function, which can handle the failure gracefully.
14
14
 
@@ -21,7 +21,7 @@ if (StepNotRegisteredError.is(error)) { // [!code highlight]
21
21
  }
22
22
  ```
23
23
 
24
- ## API Signature
24
+ ## API signature
25
25
 
26
26
  ### Properties
27
27
 
@@ -36,14 +36,14 @@ interface StepNotRegisteredError {
36
36
  export default StepNotRegisteredError;`}
37
37
  />
38
38
 
39
- ### Static Methods
39
+ ### Static methods
40
40
 
41
41
  #### `StepNotRegisteredError.is(value)`
42
42
 
43
- Type-safe check for `StepNotRegisteredError` instances. Preferred over `instanceof` because it works across module boundaries and VM contexts.
43
+ Type-safe check for `StepNotRegisteredError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
44
44
 
45
45
  <Callout>
46
- The `.is()` method works in server-side Node.js code (API routes, middleware, hooks). Inside `"use workflow"` functions, step errors arrive deserialized from the event log and won't be actual `StepNotRegisteredError` instances — use `error.message` matching instead. See the [troubleshooting page](/docs/errors/step-not-registered) for workflow-side error handling examples.
46
+ The `.is()` method works in server-side Node.js code (API routes, middleware, hooks). Inside `"use workflow"` functions, step errors arrive deserialized from the event log and won't be actual `StepNotRegisteredError` instances. Use `error.message` matching instead. See the [troubleshooting page](/docs/errors/step-not-registered) for workflow-side error handling examples.
47
47
  </Callout>
48
48
 
49
49
  ```typescript
@@ -31,7 +31,7 @@ try {
31
31
  }
32
32
  ```
33
33
 
34
- ## API Signature
34
+ ## API signature
35
35
 
36
36
  ### Properties
37
37
 
@@ -46,7 +46,7 @@ interface ThrottleError {
46
46
  export default ThrottleError;`}
47
47
  />
48
48
 
49
- ### Static Methods
49
+ ### Static methods
50
50
 
51
51
  #### `ThrottleError.is(value)`
52
52
 
@@ -31,7 +31,7 @@ try {
31
31
  }
32
32
  ```
33
33
 
34
- ## API Signature
34
+ ## API signature
35
35
 
36
36
  ### Properties
37
37
 
@@ -46,7 +46,7 @@ interface TooEarlyError {
46
46
  export default TooEarlyError;`}
47
47
  />
48
48
 
49
- ### Static Methods
49
+ ### Static methods
50
50
 
51
51
  #### `TooEarlyError.is(value)`
52
52
 
@@ -0,0 +1,52 @@
1
+ ---
2
+ title: WorkflowError
3
+ description: Base class for all workflow error types.
4
+ type: reference
5
+ summary: All errors thrown by the Workflow SDK extend WorkflowError.
6
+ related:
7
+ - /docs/foundations/errors-and-retries
8
+ ---
9
+
10
+ `WorkflowError` is the base class that all Workflow SDK error types extend, such as [`WorkflowRunFailedError`](/docs/api-reference/workflow-errors/workflow-run-failed-error) and [`HookNotFoundError`](/docs/api-reference/workflow-errors/hook-not-found-error). It extends `Error` with an optional `cause` and, for some subclasses, a link to the relevant error documentation appended to the message.
11
+
12
+ ```typescript lineNumbers
13
+ import { WorkflowError } from "workflow/errors"
14
+
15
+ const error = new WorkflowError("something went wrong", {
16
+ cause: new Error("underlying cause"),
17
+ });
18
+ ```
19
+
20
+ ## API signature
21
+
22
+ ### Properties
23
+
24
+ <TSDoc
25
+ definition={`
26
+ interface WorkflowError {
27
+ /** The error message. */
28
+ message: string;
29
+ /** The underlying cause, when provided. */
30
+ cause?: unknown;
31
+ }
32
+ export default WorkflowError;`}
33
+ />
34
+
35
+ ### Static methods
36
+
37
+ #### `WorkflowError.is(value)`
38
+
39
+ Type-safe check for `WorkflowError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
40
+
41
+ <Callout type="warn">
42
+ `WorkflowError.is()` matches only direct `WorkflowError` instances, not subclasses, which override the error name it checks. To handle a specific error type, use that subclass's own `.is()` method (e.g. `WorkflowRunFailedError.is(error)`).
43
+ </Callout>
44
+
45
+ ```typescript
46
+ import { WorkflowError } from "workflow/errors"
47
+ declare const error: unknown; // @setup
48
+
49
+ if (WorkflowError.is(error)) {
50
+ // error is typed as WorkflowError
51
+ }
52
+ ```
@@ -8,7 +8,7 @@ related:
8
8
  - /docs/api-reference/workflow-errors/step-not-registered-error
9
9
  ---
10
10
 
11
- `WorkflowNotRegisteredError` is thrown when the runtime tries to execute a workflow function that is not registered in the current deployment. This is an infrastructure error — not a user code error. It typically means a run was started against a deployment that does not have this workflow (e.g., the workflow was renamed or moved), or there was a build/bundling issue.
11
+ `WorkflowNotRegisteredError` is thrown when the runtime tries to execute a workflow function that is not registered in the current deployment. This is an infrastructure error, not a user code error. It typically means a run was started against a deployment that does not have this workflow (e.g., the workflow was renamed or moved), or there was a build/bundling issue.
12
12
 
13
13
  When this error occurs, the run fails with a `RUNTIME_ERROR` error code.
14
14
 
@@ -21,7 +21,7 @@ if (WorkflowNotRegisteredError.is(error)) { // [!code highlight]
21
21
  }
22
22
  ```
23
23
 
24
- ## API Signature
24
+ ## API signature
25
25
 
26
26
  ### Properties
27
27
 
@@ -36,14 +36,14 @@ interface WorkflowNotRegisteredError {
36
36
  export default WorkflowNotRegisteredError;`}
37
37
  />
38
38
 
39
- ### Static Methods
39
+ ### Static methods
40
40
 
41
41
  #### `WorkflowNotRegisteredError.is(value)`
42
42
 
43
- Type-safe check for `WorkflowNotRegisteredError` instances. Preferred over `instanceof` because it works across module boundaries and VM contexts.
43
+ Type-safe check for `WorkflowNotRegisteredError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
44
44
 
45
45
  <Callout>
46
- The `.is()` method works in server-side Node.js code (API routes, middleware). When checking the error from `run.returnValue`, use `WorkflowRunFailedError.is()` and inspect `error.cause` — the underlying error is deserialized from the event log.
46
+ The `.is()` method works in server-side Node.js code (API routes, middleware). When checking the error from `run.returnValue`, use `WorkflowRunFailedError.is()` and inspect `error.cause`: the underlying error is deserialized from the event log.
47
47
  </Callout>
48
48
 
49
49
  ```typescript
@@ -54,4 +54,3 @@ if (WorkflowNotRegisteredError.is(error)) {
54
54
  // error is typed as WorkflowNotRegisteredError
55
55
  }
56
56
  ```
57
-
@@ -1,17 +1,19 @@
1
1
  ---
2
2
  title: WorkflowRunCancelledError
3
- description: Thrown when awaiting the return value of a cancelled workflow run.
3
+ description: Thrown when awaiting the return value of a canceled workflow run.
4
4
  type: reference
5
- summary: Catch WorkflowRunCancelledError when awaiting run.returnValue on a run that was cancelled.
5
+ summary: Catch WorkflowRunCancelledError when awaiting run.returnValue on a run that was canceled.
6
6
  related:
7
7
  - /docs/api-reference/workflow-errors/workflow-run-failed-error
8
8
  - /docs/api-reference/workflow-errors/workflow-run-not-found-error
9
9
  ---
10
10
 
11
- `WorkflowRunCancelledError` is thrown when awaiting `run.returnValue` on a workflow run that was explicitly cancelled via `run.cancel()`. Cancelled runs do not produce a return value.
11
+ `WorkflowRunCancelledError` is thrown when awaiting `run.returnValue` on a workflow run that was explicitly canceled via `run.cancel()`. Canceled runs do not produce a return value.
12
12
 
13
13
  You can check for cancellation before awaiting by inspecting `run.status`.
14
14
 
15
+ A canceled run is terminal, so this error is non-retryable (`fatal: true`). Inside a workflow, `await run.returnValue` runs as a step, and that step fails on its first attempt instead of spending its retry budget re-reading a run that cannot change. Errors from *failing to read* the run, such as a transport blip, stay retryable.
16
+
15
17
  ```typescript lineNumbers
16
18
  import { WorkflowRunCancelledError } from "workflow/errors"
17
19
  declare const run: { status: Promise<string>; returnValue: Promise<any> }; // @setup
@@ -25,22 +27,27 @@ try {
25
27
  }
26
28
  ```
27
29
 
28
- ## API Signature
30
+ ## API signature
29
31
 
30
32
  ### Properties
31
33
 
32
34
  <TSDoc
33
35
  definition={`
34
36
  interface WorkflowRunCancelledError {
35
- /** The ID of the cancelled run. */
37
+ /** The ID of the canceled run. */
36
38
  runId: string;
39
+ /**
40
+ * Always \`true\`. A canceled run is terminal, so a step that reads one is
41
+ * not retried.
42
+ */
43
+ fatal: true;
37
44
  /** The error message. */
38
45
  message: string;
39
46
  }
40
47
  export default WorkflowRunCancelledError;`}
41
48
  />
42
49
 
43
- ### Static Methods
50
+ ### Static methods
44
51
 
45
52
  #### `WorkflowRunCancelledError.is(value)`
46
53
 
@@ -11,7 +11,9 @@ related:
11
11
 
12
12
  `WorkflowRunFailedError` is thrown when awaiting `run.returnValue` on a workflow run whose status is `'failed'`. This indicates that the workflow encountered a fatal error during execution and cannot produce a return value.
13
13
 
14
- The `cause` property holds the original thrown value, hydrated through the workflow serialization pipeline so its type identity (e.g. `FatalError`, `RetryableError`, custom `Error` subclasses), `cause` chain, and custom properties are preserved. Because any JavaScript value can be thrown, `cause` is typed as `unknown` — narrow it with `instanceof Error` (or a more specific check) before accessing fields like `message`. The high-level error classification is exposed as the top-level `errorCode` property.
14
+ The `cause` property holds the original thrown value, hydrated through the workflow serialization pipeline so its type identity (e.g. `FatalError`, `RetryableError`, custom `Error` subclasses), `cause` chain, and custom properties are preserved. Because any JavaScript value can be thrown, `cause` is typed as `unknown`, so narrow it with `instanceof Error` (or a more specific check) before accessing fields like `message`. The high-level error classification is exposed as the top-level `errorCode` property.
15
+
16
+ A failed run is terminal, so this error is non-retryable (`fatal: true`). Inside a workflow, `await run.returnValue` runs as a step, and that step fails on its first attempt instead of spending its retry budget re-reading a run that cannot change: the remote failure reaches the caller immediately, and the caller catches a `WorkflowRunFailedError` rather than a retry-exhaustion wrapper. Errors from *failing to read* the run, such as a transport blip, stay retryable.
15
17
 
16
18
  ```typescript lineNumbers
17
19
  import { WorkflowRunFailedError } from "workflow/errors"
@@ -31,7 +33,7 @@ try {
31
33
  }
32
34
  ```
33
35
 
34
- ## API Signature
36
+ ## API signature
35
37
 
36
38
  ### Properties
37
39
 
@@ -45,22 +47,27 @@ interface WorkflowRunFailedError {
45
47
  * the workflow serialization pipeline. Preserves the original type identity
46
48
  * (Error subclasses, FatalError, custom classes with WORKFLOW_SERIALIZE,
47
49
  * etc.) and custom properties. Typed as \`unknown\` because any value can
48
- * be thrown — narrow with \`instanceof Error\` before accessing fields.
50
+ * be thrown, so narrow with \`instanceof Error\` before accessing fields.
49
51
  */
50
52
  cause: unknown;
51
53
  /** The high-level error category (e.g. \`USER_ERROR\`, \`RUNTIME_ERROR\`). */
52
54
  errorCode?: string;
55
+ /**
56
+ * Always \`true\`. A failed run is terminal, so a step that reads one is not
57
+ * retried.
58
+ */
59
+ fatal: true;
53
60
  /** The error message. */
54
61
  message: string;
55
62
  }
56
63
  export default WorkflowRunFailedError;`}
57
64
  />
58
65
 
59
- ### Static Methods
66
+ ### Static methods
60
67
 
61
68
  #### `WorkflowRunFailedError.is(value)`
62
69
 
63
- Type-safe check for `WorkflowRunFailedError` instances. Preferred over `instanceof` because it works across module boundaries and VM contexts.
70
+ Type-safe check for `WorkflowRunFailedError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
64
71
 
65
72
  ```typescript
66
73
  import { WorkflowRunFailedError } from "workflow/errors"
@@ -0,0 +1,58 @@
1
+ ---
2
+ title: WorkflowRunNotCompletedError
3
+ description: Thrown when requesting the result of a workflow run that has not completed yet.
4
+ type: reference
5
+ summary: Catch WorkflowRunNotCompletedError when reading the return value of a run that is still pending or running.
6
+ related:
7
+ - /docs/api-reference/workflow-api/get-run
8
+ ---
9
+
10
+ `WorkflowRunNotCompletedError` is thrown when requesting the result of a workflow run that has not completed yet. The run's current status (for example `pending` or `running`) is available on the error.
11
+
12
+ [`run.returnValue()`](/docs/api-reference/workflow-api/get-run) handles this error internally (it polls until the run completes), so you will mainly encounter it when building custom polling logic on lower-level APIs.
13
+
14
+ ```typescript lineNumbers
15
+ import { WorkflowRunNotCompletedError } from "workflow/errors"
16
+ declare function readRunResult(runId: string): Promise<unknown>; // @setup
17
+ declare const runId: string; // @setup
18
+
19
+ try {
20
+ const result = await readRunResult(runId);
21
+ } catch (error) {
22
+ if (WorkflowRunNotCompletedError.is(error)) { // [!code highlight]
23
+ console.log(`Run ${error.runId} is still ${error.status}`);
24
+ }
25
+ }
26
+ ```
27
+
28
+ ## API signature
29
+
30
+ ### Properties
31
+
32
+ <TSDoc
33
+ definition={`
34
+ interface WorkflowRunNotCompletedError {
35
+ /** The workflow run ID. */
36
+ runId: string;
37
+ /** The run's status at the time of the error (e.g. "pending", "running"). */
38
+ status: string;
39
+ /** The error message. */
40
+ message: string;
41
+ }
42
+ export default WorkflowRunNotCompletedError;`}
43
+ />
44
+
45
+ ### Static methods
46
+
47
+ #### `WorkflowRunNotCompletedError.is(value)`
48
+
49
+ Type-safe check for `WorkflowRunNotCompletedError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
50
+
51
+ ```typescript
52
+ import { WorkflowRunNotCompletedError } from "workflow/errors"
53
+ declare const error: unknown; // @setup
54
+
55
+ if (WorkflowRunNotCompletedError.is(error)) {
56
+ // error is typed as WorkflowRunNotCompletedError
57
+ }
58
+ ```
@@ -10,7 +10,7 @@ related:
10
10
 
11
11
  `WorkflowRunNotFoundError` is thrown when performing operations on a workflow run that does not exist. This includes calling methods like `run.status`, `run.cancel()`, or awaiting `run.returnValue` on a run whose ID does not match any known workflow run.
12
12
 
13
- Note that `getRun(id)` itself is synchronous and will not throw — the error is raised when subsequent operations on the run object discover the run is missing.
13
+ `getRun(id)` itself is synchronous and will not throw. Subsequent operations on the run object raise the error when they discover the run is missing.
14
14
 
15
15
  ```typescript lineNumbers
16
16
  import { WorkflowRunNotFoundError } from "workflow/errors"
@@ -25,7 +25,7 @@ try {
25
25
  }
26
26
  ```
27
27
 
28
- ## API Signature
28
+ ## API signature
29
29
 
30
30
  ### Properties
31
31
 
@@ -40,11 +40,11 @@ interface WorkflowRunNotFoundError {
40
40
  export default WorkflowRunNotFoundError;`}
41
41
  />
42
42
 
43
- ### Static Methods
43
+ ### Static methods
44
44
 
45
45
  #### `WorkflowRunNotFoundError.is(value)`
46
46
 
47
- Type-safe check for `WorkflowRunNotFoundError` instances. Preferred over `instanceof` because it works across module boundaries and VM contexts.
47
+ Type-safe check for `WorkflowRunNotFoundError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
48
48
 
49
49
  ```typescript
50
50
  import { WorkflowRunNotFoundError } from "workflow/errors"
@@ -0,0 +1,58 @@
1
+ ---
2
+ title: WorkflowRuntimeError
3
+ description: Thrown when the workflow runtime encounters an execution error, such as serialization failures or timeouts.
4
+ type: reference
5
+ summary: Catch WorkflowRuntimeError for runtime-level failures like unserializable values or workflow timeouts.
6
+ related:
7
+ - /docs/foundations/serialization
8
+ - /docs/foundations/errors-and-retries
9
+ ---
10
+
11
+ `WorkflowRuntimeError` is thrown when the workflow runtime encounters an error executing a workflow. Common causes include:
12
+
13
+ - Values crossing the workflow/step boundary that cannot be serialized
14
+ - Workflow execution timeouts
15
+ - Invalid runtime state, such as misconfigured streams
16
+
17
+ ```typescript lineNumbers
18
+ import { WorkflowRuntimeError } from "workflow/errors"
19
+ declare function runWorkflowOperation(): Promise<void>; // @setup
20
+
21
+ try {
22
+ await runWorkflowOperation();
23
+ } catch (error) {
24
+ if (WorkflowRuntimeError.is(error)) { // [!code highlight]
25
+ console.error("Workflow runtime error:", error.message);
26
+ }
27
+ }
28
+ ```
29
+
30
+ ## API signature
31
+
32
+ ### Properties
33
+
34
+ <TSDoc
35
+ definition={`
36
+ interface WorkflowRuntimeError {
37
+ /** The error message. */
38
+ message: string;
39
+ /** The underlying cause, when provided. */
40
+ cause?: unknown;
41
+ }
42
+ export default WorkflowRuntimeError;`}
43
+ />
44
+
45
+ ### Static methods
46
+
47
+ #### `WorkflowRuntimeError.is(value)`
48
+
49
+ Type-safe check for `WorkflowRuntimeError` instances. Preferred over `instanceof` because it works across module boundaries and VM contexts.
50
+
51
+ ```typescript
52
+ import { WorkflowRuntimeError } from "workflow/errors"
53
+ declare const error: unknown; // @setup
54
+
55
+ if (WorkflowRuntimeError.is(error)) {
56
+ // error is typed as WorkflowRuntimeError
57
+ }
58
+ ```
@@ -12,7 +12,7 @@ related:
12
12
 
13
13
  `WorkflowWorldError` is the base error class for failures originating from a workflow world (storage backend). World implementations (local, Postgres, Vercel) throw subclasses of this error when storage operations fail.
14
14
 
15
- You can use `instanceof WorkflowWorldError` to catch any world-related error regardless of the specific type. Note that the static `.is()` method only matches errors constructed directly as `WorkflowWorldError` — use the subclass-specific `.is()` methods (e.g. `EntityConflictError.is()`) to match specific error types.
15
+ You can use `instanceof WorkflowWorldError` to catch any World-related error regardless of the specific type. The static `.is()` method only matches errors constructed directly as `WorkflowWorldError`. Use the subclass-specific `.is()` methods (for example, `EntityConflictError.is()`) to match specific error types.
16
16
 
17
17
  <Callout>
18
18
  Most world errors are handled automatically by the Workflow runtime. You will typically only encounter these errors when interacting with world storage APIs directly or when there are infrastructure-level issues.
@@ -33,7 +33,7 @@ try {
33
33
  }
34
34
  ```
35
35
 
36
- ## API Signature
36
+ ## API signature
37
37
 
38
38
  ### Properties
39
39
 
@@ -54,11 +54,11 @@ interface WorkflowWorldError {
54
54
  export default WorkflowWorldError;`}
55
55
  />
56
56
 
57
- ### Static Methods
57
+ ### Static methods
58
58
 
59
59
  #### `WorkflowWorldError.is(value)`
60
60
 
61
- Type-safe check that matches only errors constructed directly as `WorkflowWorldError`. Does not match subclasses like `EntityConflictError` — use `instanceof` to catch all world errors, or the subclass-specific `.is()` methods.
61
+ Type-safe check that matches only errors constructed directly as `WorkflowWorldError`. Does not match subclasses like `EntityConflictError`. Use `instanceof` to catch all world errors, or the subclass-specific `.is()` methods.
62
62
 
63
63
  ```typescript
64
64
  import { WorkflowWorldError } from "workflow/errors"
@@ -73,7 +73,7 @@ if (WorkflowWorldError.is(error)) {
73
73
 
74
74
  The following error types extend `WorkflowWorldError`:
75
75
 
76
- - [`EntityConflictError`](/docs/api-reference/workflow-errors/entity-conflict-error) — operation conflicts with entity state
77
- - [`RunExpiredError`](/docs/api-reference/workflow-errors/run-expired-error) — run has expired
78
- - [`TooEarlyError`](/docs/api-reference/workflow-errors/too-early-error) — request made before system is ready
79
- - [`ThrottleError`](/docs/api-reference/workflow-errors/throttle-error) — request was rate-limited
76
+ - [`EntityConflictError`](/docs/api-reference/workflow-errors/entity-conflict-error): operation conflicts with entity state
77
+ - [`RunExpiredError`](/docs/api-reference/workflow-errors/run-expired-error): run has expired
78
+ - [`TooEarlyError`](/docs/api-reference/workflow-errors/too-early-error): request made before system is ready
79
+ - [`ThrottleError`](/docs/api-reference/workflow-errors/throttle-error): request was rate-limited
@@ -22,29 +22,30 @@ These APIs are available but are **seeded or fixed** to ensure deterministic beh
22
22
 
23
23
  | API | Behavior |
24
24
  |-----|----------|
25
- | [`Math.random()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) | Seeded random number generator — same seed produces the same sequence every replay |
26
- | [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) / `Date.now()` / `new Date()` | Returns a fixed timestamp that advances with the workflow's logical clock |
27
- | [`crypto.getRandomValues()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) | Seeded — produces deterministic output for a given workflow run |
28
- | [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID) | Seeded — produces deterministic UUIDs for a given workflow run |
29
- | [`crypto.subtle.digest()`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest) | Passes through to the real implementation (SHA-256, etc. are deterministic by nature) |
25
+ | [`Math.random()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) | Seeded random number generator: same seed produces the same sequence every replay |
26
+ | [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) / `Date.now()` / `new Date()` | Returns the workflow's logical clock: the run's creation time until the first step result, hook payload, hook registration, wait completion or abort reaches the workflow, then the time that event was recorded, advancing as each later one is delivered. Identical on every replay of the same log |
27
+ | [`crypto.getRandomValues()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) | Seeded: produces deterministic output for a given workflow run |
28
+ | [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID) | Seeded: produces deterministic UUIDs for a given workflow run |
29
+ | [`crypto.subtle.digest()`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest) | Computed synchronously via `node:crypto` (values are byte-identical to WebCrypto), so the promise settles at a deterministic point during replay |
30
30
 
31
31
  <Callout type="info">
32
32
  You can safely use `Math.random()`, `Date.now()`, and `crypto.randomUUID()` in workflow functions. The framework ensures these return the same values across replays.
33
33
  </Callout>
34
34
 
35
- ## Web Platform APIs
35
+ ## Web platform APIs
36
36
 
37
37
  These standard Web APIs are available in workflow functions:
38
38
 
39
39
  - [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers)
40
40
  - [`TextEncoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder) / [`TextDecoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder)
41
41
  - [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) / [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
42
- - [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) / [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) — custom implementations with [special behavior in the workflow context](/docs/foundations/serialization#request--response). Body methods like `.json()` and `.text()` are automatically treated as step invocations.
42
+ - [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) / [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response): custom implementations with [special behavior in the workflow context](/docs/foundations/serialization#request--response). Body methods like `.json()` and `.text()` are automatically treated as step invocations.
43
43
  - [`console`](https://developer.mozilla.org/en-US/docs/Web/API/console)
44
44
  - [`structuredClone`](https://developer.mozilla.org/en-US/docs/Web/API/Window/structuredClone)
45
45
  - [`atob`](https://developer.mozilla.org/en-US/docs/Web/API/Window/atob) / [`btoa`](https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa)
46
+ - [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) / [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal): A durable, serializable implementation whose abort state survives replay and can be passed into steps to cancel in-flight work. See [Cancellation](/docs/foundations/cancellation).
46
47
 
47
- ## Environment Variables
48
+ ## Environment variables
48
49
 
49
50
  `process.env` is available as a **read-only, frozen** snapshot of the environment variables at the time the workflow was started. You cannot modify it.
50
51
 
@@ -53,11 +54,11 @@ export async function myWorkflow() {
53
54
  "use workflow";
54
55
 
55
56
  const apiKey = process.env.API_KEY; // works
56
- process.env.FOO = "bar"; // throws — process.env is frozen
57
+ process.env.FOO = "bar"; // throws: process.env is frozen
57
58
  }
58
59
  ```
59
60
 
60
- ## Binary Data
61
+ ## Binary data
61
62
 
62
63
  Standard JavaScript typed arrays (`Uint8Array`, `Int32Array`, `Float64Array`, etc.) are available in workflow functions.
63
64
 
@@ -92,7 +93,7 @@ target.setFromHex("48656c6c6f"); // { read: 10, written: 5 }
92
93
  These methods are polyfilled in the workflow environment. When the JavaScript runtime ships native support, the polyfill is automatically bypassed.
93
94
  </Callout>
94
95
 
95
- ## Not Available
96
+ ## Not available
96
97
 
97
98
  The following are **not available** in workflow functions. Move this logic to [step functions](/docs/foundations/workflows-and-steps#step-functions) instead.
98
99
 
@@ -100,3 +101,6 @@ The following are **not available** in workflow functions. Move this logic to [s
100
101
  - **Global `fetch`**: Use [`import { fetch } from "workflow"`](/docs/api-reference/workflow/fetch) instead. See [fetch-in-workflow](/docs/errors/fetch-in-workflow).
101
102
  - **Timers**: `setTimeout`, `setInterval`, `setImmediate`, and their `clear*` counterparts. Use [`sleep()`](/docs/api-reference/workflow/sleep) instead. See [timeout-in-workflow](/docs/errors/timeout-in-workflow).
102
103
  - **`Buffer`**: Node.js-specific API. Use `Uint8Array` with `toBase64()` / `fromBase64()` / `toHex()` / `fromHex()` for binary data encoding, or `atob()` / `btoa()` for string-based base64.
104
+ - **`WeakRef` and `FinalizationRegistry`**: Garbage collection timing is not deterministic, so observing it would make workflow code impossible to replay. (`WeakMap` and `WeakSet` remain available since they do not expose garbage collection state.)
105
+ - **`Atomics.waitAsync`**: a wall-clock timer, which cannot be replayed. Use [`sleep()`](/docs/api-reference/workflow/sleep) instead.
106
+ - **Async `WebAssembly` compilation**: The `compile`, `instantiate`, `compileStreaming`, and `instantiateStreaming` methods resolve on compile-thread timing. The synchronous `new WebAssembly.Module()` and `new WebAssembly.Instance()` constructors remain available.
@@ -0,0 +1,37 @@
1
+ ---
2
+ title: configureWorkflowController
3
+ description: Point WorkflowController at the generated workflow bundles.
4
+ type: reference
5
+ summary: Configure the directory WorkflowController loads workflow bundles from.
6
+ prerequisites:
7
+ - /docs/getting-started/nestjs
8
+ ---
9
+
10
+ Configures the output directory that [`WorkflowController`](/docs/api-reference/workflow-nest/workflow-controller) loads the generated workflow bundles (`steps.mjs`, `workflows.mjs`, `webhook.mjs`, `manifest.json`) from.
11
+
12
+ <Callout type="warn">
13
+ Deprecated. [`WorkflowModule.forRoot()`](/docs/api-reference/workflow-nest/workflow-module) provides the output directory through dependency injection, which this function predates. It writes process-global state, so two applications in one process (the usual `Test.createTestingModule` setup) overwrite each other's configuration. It is kept only so existing callers keep working.
14
+ </Callout>
15
+
16
+ `WorkflowModule.forRoot()` still calls this for you, and injected options take precedence over it. Call it yourself only when registering `WorkflowController` without the module. A controller with no configuration at all answers `503` with an explanatory message.
17
+
18
+ ## Usage
19
+
20
+ ```typescript title="src/app.module.ts" lineNumbers
21
+ import { join } from "node:path";
22
+ import { configureWorkflowController } from "workflow/nest"; // [!code highlight]
23
+
24
+ configureWorkflowController(join(process.cwd(), ".nestjs/workflow")); // [!code highlight]
25
+ ```
26
+
27
+ ## API signature
28
+
29
+ ### Parameters
30
+
31
+ | Parameter | Type | Description |
32
+ | --- | --- | --- |
33
+ | `outDir` | `string` | Directory containing the generated workflow bundles. Should match the `outDir` used by the builder (default: `.nestjs/workflow` in the working directory). |
34
+
35
+ ### Returns
36
+
37
+ Returns `void`.