workflow 5.0.0-beta.4 → 5.0.0-beta.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -20
- package/dist/api-workflow.d.ts +1 -1
- package/dist/api-workflow.d.ts.map +1 -1
- package/dist/api-workflow.js +1 -1
- package/dist/api.d.ts +5 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +12 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/internal/builtins.d.ts +17 -0
- package/dist/internal/builtins.d.ts.map +1 -1
- package/dist/internal/builtins.js +65 -1
- package/dist/internal/errors.d.ts +1 -1
- package/dist/internal/errors.d.ts.map +1 -1
- package/dist/internal/errors.js +2 -2
- package/dist/nest-builder.d.ts +2 -0
- package/dist/nest-builder.d.ts.map +1 -0
- package/dist/nest-builder.js +2 -0
- package/dist/nest-vercel-builder.d.ts +2 -0
- package/dist/nest-vercel-builder.d.ts.map +1 -0
- package/dist/nest-vercel-builder.js +2 -0
- package/dist/observability.d.ts +1 -1
- package/dist/observability.js +2 -2
- package/dist/runtime.d.ts +2 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +5 -2
- package/docs/ai/chat-session-modeling.mdx +7 -3
- package/docs/ai/defining-tools.mdx +2 -2
- package/docs/ai/index.mdx +30 -25
- package/docs/ai/message-queueing.mdx +10 -10
- package/docs/ai/resumable-streams.mdx +9 -1
- package/docs/api-reference/index.mdx +24 -0
- package/docs/api-reference/meta.json +8 -0
- package/docs/api-reference/vitest/index.mdx +28 -7
- package/docs/api-reference/workflow/create-hook.mdx +79 -0
- package/docs/api-reference/workflow/create-webhook.mdx +1 -0
- package/docs/api-reference/workflow/define-hook.mdx +26 -24
- package/docs/api-reference/workflow/fatal-error.mdx +29 -7
- package/docs/api-reference/workflow/fetch.mdx +8 -4
- package/docs/api-reference/workflow/index.mdx +3 -0
- package/docs/api-reference/workflow/set-attributes.mdx +61 -0
- package/docs/api-reference/workflow/sleep.mdx +1 -1
- package/docs/api-reference/workflow-ai/durable-agent.mdx +7 -45
- package/docs/api-reference/workflow-ai/index.mdx +2 -2
- package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +44 -1
- package/docs/api-reference/workflow-api/get-hook-by-token.mdx +9 -0
- package/docs/api-reference/workflow-api/get-run.mdx +25 -0
- package/docs/api-reference/workflow-api/index.mdx +6 -8
- package/docs/api-reference/workflow-api/resume-hook.mdx +60 -1
- package/docs/api-reference/workflow-api/resume-webhook.mdx +6 -4
- package/docs/api-reference/workflow-api/start.mdx +39 -6
- package/docs/api-reference/workflow-astro/index.mdx +18 -0
- package/docs/api-reference/workflow-astro/meta.json +4 -0
- package/docs/api-reference/workflow-astro/workflow.mdx +45 -0
- package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +60 -0
- package/docs/api-reference/workflow-errors/index.mdx +88 -0
- package/docs/api-reference/workflow-errors/meta.json +6 -0
- package/docs/api-reference/workflow-errors/precondition-failed-error.mdx +68 -0
- package/docs/api-reference/workflow-errors/run-not-supported-error.mdx +58 -0
- package/docs/api-reference/workflow-errors/workflow-error.mdx +52 -0
- package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +16 -6
- package/docs/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +58 -0
- package/docs/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
- package/docs/api-reference/workflow-globals.mdx +4 -1
- package/docs/api-reference/workflow-nest/configure-workflow-controller.mdx +33 -0
- package/docs/api-reference/workflow-nest/index.mdx +31 -0
- package/docs/api-reference/workflow-nest/meta.json +9 -0
- package/docs/api-reference/workflow-nest/nest-local-builder.mdx +64 -0
- package/docs/api-reference/workflow-nest/workflow-controller.mdx +40 -0
- package/docs/api-reference/workflow-nest/workflow-module.mdx +74 -0
- package/docs/api-reference/workflow-next/with-workflow.mdx +56 -2
- package/docs/api-reference/workflow-nitro/index.mdx +60 -0
- package/docs/api-reference/workflow-nuxt/index.mdx +48 -0
- package/docs/api-reference/workflow-observability/hydrate-data.mdx +35 -0
- package/docs/api-reference/workflow-observability/hydrate-resource-io.mdx +62 -0
- package/docs/api-reference/workflow-observability/index.mdx +64 -0
- package/docs/api-reference/workflow-observability/meta.json +11 -0
- package/docs/api-reference/workflow-observability/observability-revivers.mdx +50 -0
- package/docs/api-reference/workflow-observability/parse-class-name.mdx +41 -0
- package/docs/api-reference/workflow-observability/parse-step-name.mdx +40 -0
- package/docs/api-reference/workflow-observability/parse-workflow-name.mdx +55 -0
- package/docs/api-reference/workflow-runtime/create-world.mdx +39 -0
- package/docs/api-reference/workflow-runtime/get-world-handlers.mdx +44 -0
- package/docs/api-reference/{workflow-api → workflow-runtime}/get-world.mdx +7 -10
- package/docs/api-reference/workflow-runtime/health-check.mdx +50 -0
- package/docs/api-reference/workflow-runtime/index.mdx +43 -0
- package/docs/api-reference/workflow-runtime/meta.json +12 -0
- package/docs/api-reference/workflow-runtime/set-world.mdx +49 -0
- package/docs/api-reference/workflow-runtime/workflow-entrypoint.mdx +42 -0
- package/docs/api-reference/workflow-runtime/world/analytics.mdx +138 -0
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/index.mdx +10 -10
- package/docs/api-reference/workflow-runtime/world/meta.json +4 -0
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/queue.mdx +8 -6
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/storage.mdx +18 -5
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/streams.mdx +2 -2
- package/docs/api-reference/workflow-serde/index.mdx +0 -1
- package/docs/api-reference/workflow-serde/workflow-deserialize.mdx +1 -2
- package/docs/api-reference/workflow-serde/workflow-serialize.mdx +2 -2
- package/docs/api-reference/workflow-sveltekit/index.mdx +18 -0
- package/docs/api-reference/workflow-sveltekit/meta.json +4 -0
- package/docs/api-reference/workflow-sveltekit/workflow-plugin.mdx +42 -0
- package/docs/api-reference/workflow-vite/index.mdx +18 -0
- package/docs/api-reference/workflow-vite/meta.json +4 -0
- package/docs/api-reference/workflow-vite/workflow.mdx +48 -0
- package/docs/changelog/attributes-mvp.mdx +380 -0
- package/docs/changelog/eager-processing.mdx +269 -0
- package/docs/changelog/index.mdx +3 -1
- package/docs/changelog/lazy-event-creation.md +127 -0
- package/docs/changelog/meta.json +9 -1
- package/docs/changelog/resilient-resume.mdx +22 -0
- package/docs/changelog/resilient-start.mdx +31 -283
- package/docs/changelog/step-message-ownership.mdx +360 -0
- package/docs/changelog/turbo-mode.md +87 -0
- package/docs/comparisons/index.mdx +66 -0
- package/docs/comparisons/meta.json +11 -0
- package/docs/comparisons/workflow-sdk-vs-aws-agentcore.mdx +55 -0
- package/docs/comparisons/workflow-sdk-vs-aws-step-functions.mdx +111 -0
- package/docs/comparisons/workflow-sdk-vs-cloudflare-workflows.mdx +71 -0
- package/docs/comparisons/workflow-sdk-vs-inngest.mdx +102 -0
- package/docs/comparisons/workflow-sdk-vs-temporal.mdx +123 -0
- package/docs/comparisons/workflow-sdk-vs-trigger-dev.mdx +103 -0
- package/docs/configuration/build-and-diagnostics.mdx +70 -0
- package/docs/configuration/cli-and-web-ui.mdx +182 -0
- package/docs/configuration/framework-options.mdx +165 -0
- package/docs/configuration/index.mdx +32 -0
- package/docs/configuration/meta.json +12 -0
- package/docs/configuration/runtime-tuning.mdx +276 -0
- package/docs/configuration/worlds.mdx +275 -0
- package/docs/cookbook/advanced/child-workflows.mdx +203 -256
- package/docs/cookbook/advanced/meta.json +1 -1
- package/docs/cookbook/advanced/publishing-libraries.mdx +33 -24
- package/docs/cookbook/advanced/serializable-steps.mdx +12 -4
- package/docs/cookbook/advanced/upgrading-workflows.mdx +199 -0
- package/docs/cookbook/agent-patterns/agent-cancellation.mdx +34 -75
- package/docs/cookbook/agent-patterns/durable-agent.mdx +14 -142
- package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +11 -3
- package/docs/cookbook/common-patterns/batching.mdx +4 -0
- package/docs/cookbook/common-patterns/idempotency.mdx +40 -52
- package/docs/cookbook/common-patterns/rate-limiting.mdx +5 -1
- package/docs/cookbook/common-patterns/saga.mdx +6 -2
- package/docs/cookbook/common-patterns/scheduling.mdx +12 -0
- package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +4 -0
- package/docs/cookbook/common-patterns/timeouts.mdx +6 -1
- package/docs/cookbook/common-patterns/webhooks.mdx +4 -0
- package/docs/cookbook/common-patterns/workflow-composition.mdx +19 -16
- package/docs/cookbook/index.mdx +3 -3
- package/docs/cookbook/integrations/ai-sdk.mdx +64 -28
- package/docs/cookbook/integrations/chat-sdk.mdx +17 -0
- package/docs/cookbook/integrations/sandbox.mdx +17 -0
- package/docs/{deploying/index.mdx → deploying.mdx} +7 -7
- package/docs/errors/abort-signal-timeout-in-workflow.mdx +84 -0
- package/docs/errors/corrupted-event-log.mdx +5 -5
- package/docs/errors/deployment-mismatch.mdx +71 -0
- package/docs/errors/fetch-in-workflow.mdx +4 -0
- package/docs/errors/hook-conflict.mdx +60 -4
- package/docs/errors/index.mdx +1 -35
- package/docs/errors/node-js-module-in-workflow.mdx +4 -0
- package/docs/errors/replay-divergence.mdx +27 -0
- package/docs/errors/runtime-decryption-failed.mdx +77 -0
- package/docs/errors/serialization-failed.mdx +4 -0
- package/docs/errors/start-invalid-workflow-function.mdx +4 -0
- package/docs/errors/step-executed-multiple-times.mdx +23 -0
- package/docs/errors/step-not-registered.mdx +1 -1
- package/docs/errors/timeout-in-workflow.mdx +4 -0
- package/docs/errors/webhook-response-not-sent.mdx +4 -0
- package/docs/foundations/cancellation.mdx +459 -0
- package/docs/foundations/errors-and-retries.mdx +7 -3
- package/docs/foundations/hooks.mdx +29 -0
- package/docs/foundations/idempotency.mdx +243 -11
- package/docs/foundations/index.mdx +1 -23
- package/docs/foundations/meta.json +3 -1
- package/docs/foundations/serialization.mdx +77 -41
- package/docs/foundations/starting-workflows.mdx +79 -2
- package/docs/foundations/streaming.mdx +14 -23
- package/docs/foundations/versioning.mdx +263 -0
- package/docs/getting-started/astro.mdx +12 -2
- package/docs/getting-started/express.mdx +6 -2
- package/docs/getting-started/fastify.mdx +6 -2
- package/docs/getting-started/hono.mdx +6 -2
- package/docs/getting-started/index.mdx +16 -10
- package/docs/getting-started/meta.json +4 -1
- package/docs/getting-started/nestjs.mdx +77 -3
- package/docs/getting-started/next.mdx +12 -6
- package/docs/getting-started/nitro.mdx +28 -2
- package/docs/getting-started/nuxt.mdx +6 -2
- package/docs/getting-started/python.mdx +24 -18
- package/docs/getting-started/react-router/index.mdx +33 -0
- package/docs/getting-started/react-router/meta.json +5 -0
- package/docs/getting-started/react-router/v7.mdx +237 -0
- package/docs/getting-started/react-router/v8.mdx +232 -0
- package/docs/getting-started/sveltekit.mdx +12 -2
- package/docs/getting-started/tanstack-start.mdx +245 -0
- package/docs/getting-started/vite.mdx +6 -2
- package/docs/how-it-works/cancellation.mdx +287 -0
- package/docs/how-it-works/code-transform.mdx +21 -17
- package/docs/how-it-works/encryption.mdx +5 -5
- package/docs/how-it-works/event-sourcing.mdx +6 -6
- package/docs/how-it-works/framework-integrations.mdx +96 -337
- package/docs/how-it-works/meta.json +2 -1
- package/docs/internal/index.mdx +21 -0
- package/docs/internal/meta.json +10 -0
- package/docs/internal/nitro-native-build.mdx +38 -0
- package/docs/internal/nitro-web-ui.mdx +24 -0
- package/docs/internal/serializable-abort-controller.mdx +148 -0
- package/docs/meta.json +2 -2
- package/docs/observability/attributes.mdx +112 -0
- package/docs/observability/index.mdx +20 -1
- package/docs/observability/meta.json +1 -1
- package/docs/observability/tracing.mdx +124 -0
- package/docs/testing/index.mdx +2 -2
- package/package.json +17 -13
- package/docs/api-reference/workflow-api/world/meta.json +0 -4
- package/docs/api-reference/workflow-api/world/observability.mdx +0 -164
- package/docs/cookbook/advanced/distributed-abort-controller.mdx +0 -318
- package/docs/deploying/building-a-world.mdx +0 -251
- package/docs/deploying/meta.json +0 -4
- package/docs/deploying/world/local-world.mdx +0 -84
- package/docs/deploying/world/meta.json +0 -4
- package/docs/deploying/world/postgres-world.mdx +0 -222
- package/docs/deploying/world/vercel-world.mdx +0 -179
- package/docs/migration-guides/index.mdx +0 -34
- package/docs/migration-guides/meta.json +0 -9
- package/docs/migration-guides/migrating-from-aws-step-functions.mdx +0 -363
- package/docs/migration-guides/migrating-from-inngest.mdx +0 -314
- package/docs/migration-guides/migrating-from-temporal.mdx +0 -318
- package/docs/migration-guides/migrating-from-trigger-dev.mdx +0 -337
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: workflow
|
|
3
|
+
description: Configure Astro to transform workflow directives.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Add the workflow integration to your Astro config to enable workflow directive transformation.
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/getting-started/astro
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
Returns an Astro integration that transforms workflow code (`"use step"`/`"use workflow"` directives) and builds the workflow bundles.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
To enable `"use step"` and `"use workflow"` directives while developing locally or deploying to production, add `workflow()` to the `integrations` array of your Astro config.
|
|
15
|
+
|
|
16
|
+
```typescript title="astro.config.mjs" lineNumbers
|
|
17
|
+
// @ts-check
|
|
18
|
+
import { defineConfig } from "astro/config";
|
|
19
|
+
import { workflow } from "workflow/astro"; // [!code highlight]
|
|
20
|
+
|
|
21
|
+
// https://astro.build/config
|
|
22
|
+
export default defineConfig({
|
|
23
|
+
integrations: [workflow()], // [!code highlight]
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The integration registers the workflow Vite transform plugins during `astro:config:setup` and builds the workflow bundles — locally during config setup, or via the Vercel builder after `astro:build:done` when deploying to Vercel.
|
|
28
|
+
|
|
29
|
+
## API Signature
|
|
30
|
+
|
|
31
|
+
### Parameters
|
|
32
|
+
|
|
33
|
+
| Parameter | Type | Description |
|
|
34
|
+
| --- | --- | --- |
|
|
35
|
+
| `options` | `WorkflowPluginOptions` | Optional. Configures the workflow build. |
|
|
36
|
+
|
|
37
|
+
#### WorkflowPluginOptions
|
|
38
|
+
|
|
39
|
+
| Option | Type | Default | Description |
|
|
40
|
+
| --- | --- | --- | --- |
|
|
41
|
+
| `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` (dev) / `false` (prod) | Controls source maps on generated workflow bundles. Accepts the same values as esbuild's `sourcemap` option. Defaults to `'inline'` in development and `false` in production (smaller function bundles — helps stay under the Vercel 250MB function size limit). Set it explicitly, or use the `WORKFLOW_SOURCEMAP` environment variable, to override in either environment. |
|
|
42
|
+
|
|
43
|
+
### Returns
|
|
44
|
+
|
|
45
|
+
Returns an `AstroIntegration` object to include in the `integrations` array of your Astro config.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HookConflictError
|
|
3
|
+
description: Thrown when creating a hook with a token that is already in use by another workflow run.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Catch HookConflictError when a hook token is already claimed by another active workflow run.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/api-reference/workflow/create-hook
|
|
8
|
+
- /docs/foundations/hooks
|
|
9
|
+
- /docs/errors/hook-conflict
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
`HookConflictError` is thrown when creating a hook with a token that is already in use by another active workflow run. Hook tokens must be unique across all running workflows — see the [hook-conflict](/docs/errors/hook-conflict) error guide for resolution strategies.
|
|
13
|
+
|
|
14
|
+
```typescript lineNumbers
|
|
15
|
+
import { HookConflictError } from "workflow/errors"
|
|
16
|
+
declare function startApprovalWorkflow(token: string): Promise<void>; // @setup
|
|
17
|
+
declare const token: string; // @setup
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
await startApprovalWorkflow(token);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (HookConflictError.is(error)) { // [!code highlight]
|
|
23
|
+
console.error(
|
|
24
|
+
`Token "${error.token}" already in use by run ${error.conflictingRunId}`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## API Signature
|
|
31
|
+
|
|
32
|
+
### Properties
|
|
33
|
+
|
|
34
|
+
<TSDoc
|
|
35
|
+
definition={`
|
|
36
|
+
interface HookConflictError {
|
|
37
|
+
/** The hook token that conflicted. */
|
|
38
|
+
token: string;
|
|
39
|
+
/** The run ID of the workflow currently holding the token, when known. */
|
|
40
|
+
conflictingRunId?: string;
|
|
41
|
+
/** The error message. */
|
|
42
|
+
message: string;
|
|
43
|
+
}
|
|
44
|
+
export default HookConflictError;`}
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
### Static Methods
|
|
48
|
+
|
|
49
|
+
#### `HookConflictError.is(value)`
|
|
50
|
+
|
|
51
|
+
Type-safe check for `HookConflictError` instances. Preferred over `instanceof` because it works across module boundaries and VM contexts.
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { HookConflictError } from "workflow/errors"
|
|
55
|
+
declare const error: unknown; // @setup
|
|
56
|
+
|
|
57
|
+
if (HookConflictError.is(error)) {
|
|
58
|
+
// error is typed as HookConflictError
|
|
59
|
+
}
|
|
60
|
+
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "workflow/errors"
|
|
3
|
+
description: Semantic error types thrown by the Workflow SDK and its storage backends.
|
|
4
|
+
type: overview
|
|
5
|
+
summary: Explore the error classes exported from workflow/errors for handling workflow failures.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/foundations/errors-and-retries
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
API reference for the error classes exported from the `workflow/errors` package.
|
|
11
|
+
|
|
12
|
+
All errors extend [`WorkflowError`](/docs/api-reference/workflow-errors/workflow-error), so you can catch any SDK error with a single `instanceof` check, or narrow to a specific class for fine-grained handling.
|
|
13
|
+
|
|
14
|
+
## Base Classes
|
|
15
|
+
|
|
16
|
+
<Cards>
|
|
17
|
+
<Card href="/docs/api-reference/workflow-errors/workflow-error" title="WorkflowError">
|
|
18
|
+
Base class for all workflow error types.
|
|
19
|
+
</Card>
|
|
20
|
+
<Card href="/docs/api-reference/workflow-errors/workflow-world-error" title="WorkflowWorldError">
|
|
21
|
+
Base error for failures from workflow storage backends.
|
|
22
|
+
</Card>
|
|
23
|
+
</Cards>
|
|
24
|
+
|
|
25
|
+
## Registration Errors
|
|
26
|
+
|
|
27
|
+
<Cards>
|
|
28
|
+
<Card href="/docs/api-reference/workflow-errors/workflow-not-registered-error" title="WorkflowNotRegisteredError">
|
|
29
|
+
Thrown when a workflow function is not registered in the current deployment.
|
|
30
|
+
</Card>
|
|
31
|
+
<Card href="/docs/api-reference/workflow-errors/step-not-registered-error" title="StepNotRegisteredError">
|
|
32
|
+
Thrown when a step function is not registered in the current deployment.
|
|
33
|
+
</Card>
|
|
34
|
+
</Cards>
|
|
35
|
+
|
|
36
|
+
## Run Errors
|
|
37
|
+
|
|
38
|
+
<Cards>
|
|
39
|
+
<Card href="/docs/api-reference/workflow-errors/workflow-run-not-found-error" title="WorkflowRunNotFoundError">
|
|
40
|
+
Thrown when operating on a workflow run that does not exist.
|
|
41
|
+
</Card>
|
|
42
|
+
<Card href="/docs/api-reference/workflow-errors/workflow-run-failed-error" title="WorkflowRunFailedError">
|
|
43
|
+
Thrown when awaiting the return value of a failed workflow run.
|
|
44
|
+
</Card>
|
|
45
|
+
<Card href="/docs/api-reference/workflow-errors/workflow-run-cancelled-error" title="WorkflowRunCancelledError">
|
|
46
|
+
Thrown when awaiting the return value of a cancelled workflow run.
|
|
47
|
+
</Card>
|
|
48
|
+
<Card href="/docs/api-reference/workflow-errors/workflow-run-not-completed-error" title="WorkflowRunNotCompletedError">
|
|
49
|
+
Thrown when requesting the result of a workflow run that has not completed yet.
|
|
50
|
+
</Card>
|
|
51
|
+
<Card href="/docs/api-reference/workflow-errors/workflow-runtime-error" title="WorkflowRuntimeError">
|
|
52
|
+
Thrown when the workflow runtime encounters an execution error, such as serialization failures or timeouts.
|
|
53
|
+
</Card>
|
|
54
|
+
<Card href="/docs/api-reference/workflow-errors/run-expired-error" title="RunExpiredError">
|
|
55
|
+
Thrown when a workflow run has expired and can no longer be operated on.
|
|
56
|
+
</Card>
|
|
57
|
+
<Card href="/docs/api-reference/workflow-errors/run-not-supported-error" title="RunNotSupportedError">
|
|
58
|
+
Thrown when a workflow run requires a newer workflow spec version than the installed SDK supports.
|
|
59
|
+
</Card>
|
|
60
|
+
</Cards>
|
|
61
|
+
|
|
62
|
+
## Hook Errors
|
|
63
|
+
|
|
64
|
+
<Cards>
|
|
65
|
+
<Card href="/docs/api-reference/workflow-errors/hook-not-found-error" title="HookNotFoundError">
|
|
66
|
+
Thrown when resuming a hook that does not exist.
|
|
67
|
+
</Card>
|
|
68
|
+
<Card href="/docs/api-reference/workflow-errors/hook-conflict-error" title="HookConflictError">
|
|
69
|
+
Thrown when creating a hook with a token that is already in use by another workflow run.
|
|
70
|
+
</Card>
|
|
71
|
+
</Cards>
|
|
72
|
+
|
|
73
|
+
## Backend Errors
|
|
74
|
+
|
|
75
|
+
<Cards>
|
|
76
|
+
<Card href="/docs/api-reference/workflow-errors/throttle-error" title="ThrottleError">
|
|
77
|
+
Thrown when a request is rate-limited by the workflow backend.
|
|
78
|
+
</Card>
|
|
79
|
+
<Card href="/docs/api-reference/workflow-errors/entity-conflict-error" title="EntityConflictError">
|
|
80
|
+
Thrown when a storage operation conflicts with the current entity state.
|
|
81
|
+
</Card>
|
|
82
|
+
<Card href="/docs/api-reference/workflow-errors/precondition-failed-error" title="PreconditionFailedError">
|
|
83
|
+
Thrown when an event creation is rejected because the client's event-log snapshot is stale.
|
|
84
|
+
</Card>
|
|
85
|
+
<Card href="/docs/api-reference/workflow-errors/too-early-error" title="TooEarlyError">
|
|
86
|
+
Thrown when a request is made before the system is ready to process it.
|
|
87
|
+
</Card>
|
|
88
|
+
</Cards>
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"title": "workflow/errors",
|
|
3
3
|
"pages": [
|
|
4
|
+
"workflow-error",
|
|
4
5
|
"hook-not-found-error",
|
|
6
|
+
"hook-conflict-error",
|
|
5
7
|
"step-not-registered-error",
|
|
6
8
|
"workflow-not-registered-error",
|
|
7
9
|
"workflow-run-not-found-error",
|
|
8
10
|
"workflow-run-failed-error",
|
|
9
11
|
"workflow-run-cancelled-error",
|
|
12
|
+
"workflow-run-not-completed-error",
|
|
13
|
+
"workflow-runtime-error",
|
|
10
14
|
"workflow-world-error",
|
|
11
15
|
"throttle-error",
|
|
12
16
|
"entity-conflict-error",
|
|
17
|
+
"precondition-failed-error",
|
|
13
18
|
"run-expired-error",
|
|
19
|
+
"run-not-supported-error",
|
|
14
20
|
"too-early-error"
|
|
15
21
|
]
|
|
16
22
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: PreconditionFailedError
|
|
3
|
+
description: Thrown when an event creation is rejected because the client's event-log snapshot is stale.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Catch PreconditionFailedError when a world rejects an event creation made from a stale event-log snapshot.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/api-reference/workflow-errors/workflow-world-error
|
|
8
|
+
- /docs/api-reference/workflow-errors/entity-conflict-error
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
`PreconditionFailedError` is thrown by world implementations when an event creation is rejected because the client's event-log snapshot is stale — either a newer out-of-band event (such as a received hook or a completed step) was recorded after the snapshot the client replayed from, or the snapshot is missing an event recorded at or before it. It corresponds to HTTP 412 Precondition Failed semantics.
|
|
12
|
+
|
|
13
|
+
This only occurs while the optimistic-concurrency guard is enabled (`WORKFLOW_PRECONDITION_GUARD`, on by default — see [Runtime Tuning](/docs/configuration/runtime-tuning)); event creations that carry no snapshot are never rejected with this error.
|
|
14
|
+
|
|
15
|
+
A world rejects only on evidence and accepts the creation whenever it cannot decide, so this error always means the snapshot really was stale — but not receiving it does not prove the snapshot was current.
|
|
16
|
+
|
|
17
|
+
<Callout>
|
|
18
|
+
The Workflow runtime handles this error automatically: it restarts the replay in the same invocation from a corrected event log, and re-invokes the run for a fresh replay only once its in-process restart budget is spent. It never retries the rejected creation as-is, because a replay working from a corrected log derives different events. You will only encounter it when interacting with world storage APIs directly.
|
|
19
|
+
</Callout>
|
|
20
|
+
|
|
21
|
+
A world may attach the events the client was missing to the rejection as `details`, which lets the runtime restart without re-reading the event log. Doing so is optional, and the runtime falls back to a full reload when the details are absent or unusable.
|
|
22
|
+
|
|
23
|
+
```typescript lineNumbers
|
|
24
|
+
import { PreconditionFailedError } from "workflow/errors"
|
|
25
|
+
declare const world: { events: { create(...args: any[]): Promise<any> } }; // @setup
|
|
26
|
+
declare const runId: string; // @setup
|
|
27
|
+
declare const event: any; // @setup
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
await world.events.create(runId, event);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if (PreconditionFailedError.is(error)) { // [!code highlight]
|
|
33
|
+
console.log("Snapshot is stale; reload the event log and retry");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API Signature
|
|
39
|
+
|
|
40
|
+
### Properties
|
|
41
|
+
|
|
42
|
+
<TSDoc
|
|
43
|
+
definition={`
|
|
44
|
+
interface PreconditionFailedError {
|
|
45
|
+
/** Delay in seconds before the operation should be retried. Present when the server sends a Retry-After header. */
|
|
46
|
+
retryAfter?: number;
|
|
47
|
+
/** Optional rejection payload. A world may put the events the client was missing here, as \`{ events, cursor }\`, so the runtime can restart its replay without re-reading the event log. */
|
|
48
|
+
details?: unknown;
|
|
49
|
+
/** The error message. */
|
|
50
|
+
message: string;
|
|
51
|
+
}
|
|
52
|
+
export default PreconditionFailedError;`}
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
### Static Methods
|
|
56
|
+
|
|
57
|
+
#### `PreconditionFailedError.is(value)`
|
|
58
|
+
|
|
59
|
+
Type-safe check for `PreconditionFailedError` instances. Preferred over `instanceof` because it works across module boundaries and VM contexts.
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { PreconditionFailedError } from "workflow/errors"
|
|
63
|
+
declare const error: unknown; // @setup
|
|
64
|
+
|
|
65
|
+
if (PreconditionFailedError.is(error)) {
|
|
66
|
+
// error is typed as PreconditionFailedError
|
|
67
|
+
}
|
|
68
|
+
```
|
|
@@ -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 VM 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
|
+
```
|
|
@@ -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 VM 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
|
+
```
|
|
@@ -11,7 +11,7 @@ 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
|
|
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.
|
|
15
15
|
|
|
16
16
|
```typescript lineNumbers
|
|
17
17
|
import { WorkflowRunFailedError } from "workflow/errors"
|
|
@@ -21,9 +21,11 @@ try {
|
|
|
21
21
|
const result = await run.returnValue;
|
|
22
22
|
} catch (error) {
|
|
23
23
|
if (WorkflowRunFailedError.is(error)) { // [!code highlight]
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
if (error.cause instanceof Error) {
|
|
25
|
+
console.error(`Run ${error.runId} failed:`, error.cause.message);
|
|
26
|
+
}
|
|
27
|
+
if (error.errorCode) {
|
|
28
|
+
console.error("Error code:", error.errorCode);
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
}
|
|
@@ -38,8 +40,16 @@ definition={`
|
|
|
38
40
|
interface WorkflowRunFailedError {
|
|
39
41
|
/** The ID of the failed run. */
|
|
40
42
|
runId: string;
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
+
/**
|
|
44
|
+
* The original thrown value from the failed workflow run, hydrated through
|
|
45
|
+
* the workflow serialization pipeline. Preserves the original type identity
|
|
46
|
+
* (Error subclasses, FatalError, custom classes with WORKFLOW_SERIALIZE,
|
|
47
|
+
* etc.) and custom properties. Typed as \`unknown\` because any value can
|
|
48
|
+
* be thrown — narrow with \`instanceof Error\` before accessing fields.
|
|
49
|
+
*/
|
|
50
|
+
cause: unknown;
|
|
51
|
+
/** The high-level error category (e.g. \`USER_ERROR\`, \`RUNTIME_ERROR\`). */
|
|
52
|
+
errorCode?: string;
|
|
43
53
|
/** The error message. */
|
|
44
54
|
message: string;
|
|
45
55
|
}
|
|
@@ -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 VM 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
|
+
```
|
|
@@ -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
|
+
```
|
|
@@ -26,7 +26,7 @@ These APIs are available but are **seeded or fixed** to ensure deterministic beh
|
|
|
26
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
27
|
| [`crypto.getRandomValues()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) | Seeded — produces deterministic output for a given workflow run |
|
|
28
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) |
|
|
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.
|
|
@@ -100,3 +100,6 @@ The following are **not available** in workflow functions. Move this logic to [s
|
|
|
100
100
|
- **Global `fetch`**: Use [`import { fetch } from "workflow"`](/docs/api-reference/workflow/fetch) instead. See [fetch-in-workflow](/docs/errors/fetch-in-workflow).
|
|
101
101
|
- **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
102
|
- **`Buffer`**: Node.js-specific API. Use `Uint8Array` with `toBase64()` / `fromBase64()` / `toHex()` / `fromHex()` for binary data encoding, or `atob()` / `btoa()` for string-based base64.
|
|
103
|
+
- **`WeakRef` and `FinalizationRegistry`**: garbage-collection timing is not deterministic, so observing it would make workflow code impossible to replay. (`WeakMap` and `WeakSet` remain available — they do not expose GC state.)
|
|
104
|
+
- **`Atomics.waitAsync`**: a wall-clock timer, which cannot be replayed. Use [`sleep()`](/docs/api-reference/workflow/sleep) instead.
|
|
105
|
+
- **Async `WebAssembly` compilation** (`compile`, `instantiate`, `compileStreaming`, `instantiateStreaming`): resolves on compile-thread timing. The synchronous `new WebAssembly.Module()` and `new WebAssembly.Instance()` constructors remain available.
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
[`WorkflowModule.forRoot()`](/docs/api-reference/workflow-nest/workflow-module) calls this for you with its resolved `outDir` — call it yourself only when registering `WorkflowController` manually. The controller's route handlers throw if no directory has been configured.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```typescript title="src/app.module.ts" lineNumbers
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
import { configureWorkflowController } from "workflow/nest"; // [!code highlight]
|
|
19
|
+
|
|
20
|
+
configureWorkflowController(join(process.cwd(), ".nestjs/workflow")); // [!code highlight]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## API Signature
|
|
24
|
+
|
|
25
|
+
### Parameters
|
|
26
|
+
|
|
27
|
+
| Parameter | Type | Description |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| `outDir` | `string` | Directory containing the generated workflow bundles. Should match the `outDir` used by the builder (default: `.nestjs/workflow` in the working directory). |
|
|
30
|
+
|
|
31
|
+
### Returns
|
|
32
|
+
|
|
33
|
+
Returns `void`.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "workflow/nest"
|
|
3
|
+
description: NestJS integration for workflow bundling and HTTP routing.
|
|
4
|
+
type: overview
|
|
5
|
+
summary: Explore the NestJS integration for workflow bundle building and runtime routing.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/getting-started/nestjs
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
NestJS integration for Workflow SDK. The `WorkflowModule` builds the workflow bundles on application startup and registers the controller that serves the workflow runtime routes.
|
|
11
|
+
|
|
12
|
+
<Callout>
|
|
13
|
+
NestJS integration is experimental and not yet supported for deployment to Vercel. The same exports are also available from the `@workflow/nest` package.
|
|
14
|
+
</Callout>
|
|
15
|
+
|
|
16
|
+
## Exports
|
|
17
|
+
|
|
18
|
+
<Cards>
|
|
19
|
+
<Card title="WorkflowModule" href="/docs/api-reference/workflow-nest/workflow-module">
|
|
20
|
+
NestJS module that builds workflow bundles on startup and registers the workflow controller
|
|
21
|
+
</Card>
|
|
22
|
+
<Card title="NestLocalBuilder" href="/docs/api-reference/workflow-nest/nest-local-builder">
|
|
23
|
+
Builder that compiles workflow files into step, workflow, and webhook bundles
|
|
24
|
+
</Card>
|
|
25
|
+
<Card title="WorkflowController" href="/docs/api-reference/workflow-nest/workflow-controller">
|
|
26
|
+
Controller that serves the workflow runtime routes under `.well-known/workflow/v1`
|
|
27
|
+
</Card>
|
|
28
|
+
<Card title="configureWorkflowController()" href="/docs/api-reference/workflow-nest/configure-workflow-controller">
|
|
29
|
+
Points `WorkflowController` at the directory containing the generated workflow bundles
|
|
30
|
+
</Card>
|
|
31
|
+
</Cards>
|