workflow 5.0.0-beta.43 → 5.0.0-beta.46
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 +6 -4
- package/dist/internal/builtins.d.ts +4 -4
- package/dist/internal/builtins.js +6 -6
- package/docs/ai/chat-session-modeling.mdx +23 -24
- package/docs/ai/defining-tools.mdx +5 -6
- package/docs/ai/human-in-the-loop.mdx +11 -11
- package/docs/ai/index.mdx +20 -20
- package/docs/ai/message-queueing.mdx +6 -6
- package/docs/ai/meta.json +1 -0
- package/docs/ai/resumable-streams.mdx +28 -28
- package/docs/ai/sleep-and-delays.mdx +9 -9
- package/docs/ai/streaming-updates-from-tools.mdx +4 -4
- package/docs/api-reference/vitest/index.mdx +8 -8
- package/docs/api-reference/workflow/create-hook.mdx +15 -15
- package/docs/api-reference/workflow/create-webhook.mdx +15 -15
- package/docs/api-reference/workflow/define-hook.mdx +10 -10
- package/docs/api-reference/workflow/fatal-error.mdx +2 -2
- package/docs/api-reference/workflow/fetch.mdx +7 -7
- package/docs/api-reference/workflow/get-step-metadata.mdx +2 -2
- package/docs/api-reference/workflow/get-workflow-metadata.mdx +3 -3
- package/docs/api-reference/workflow/get-writable.mdx +7 -7
- package/docs/api-reference/workflow/index.mdx +1 -1
- package/docs/api-reference/workflow/retryable-error.mdx +1 -1
- package/docs/api-reference/workflow/set-attributes.mdx +2 -2
- package/docs/api-reference/workflow/sleep.mdx +3 -3
- package/docs/api-reference/workflow-ai/durable-agent.mdx +42 -42
- package/docs/api-reference/workflow-ai/index.mdx +3 -3
- package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +28 -28
- package/docs/api-reference/workflow-api/get-hook-by-token.mdx +11 -11
- package/docs/api-reference/workflow-api/get-run.mdx +10 -10
- package/docs/api-reference/workflow-api/index.mdx +2 -4
- package/docs/api-reference/workflow-api/resume-hook.mdx +16 -16
- package/docs/api-reference/workflow-api/resume-webhook.mdx +4 -4
- package/docs/api-reference/workflow-api/start.mdx +16 -15
- package/docs/api-reference/workflow-astro/workflow.mdx +3 -3
- package/docs/api-reference/workflow-errors/entity-conflict-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/hook-not-found-error.mdx +8 -8
- package/docs/api-reference/workflow-errors/index.mdx +6 -6
- package/docs/api-reference/workflow-errors/precondition-failed-error.mdx +9 -9
- package/docs/api-reference/workflow-errors/run-expired-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/run-not-supported-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/step-not-registered-error.mdx +5 -5
- package/docs/api-reference/workflow-errors/throttle-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/too-early-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/workflow-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/workflow-not-registered-error.mdx +5 -6
- package/docs/api-reference/workflow-errors/workflow-run-cancelled-error.mdx +6 -6
- package/docs/api-reference/workflow-errors/workflow-run-failed-error.mdx +5 -5
- package/docs/api-reference/workflow-errors/workflow-run-not-completed-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/workflow-run-not-found-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/workflow-runtime-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/workflow-world-error.mdx +8 -8
- package/docs/api-reference/workflow-globals.mdx +12 -11
- package/docs/api-reference/workflow-nest/configure-workflow-controller.mdx +2 -2
- package/docs/api-reference/workflow-nest/nest-local-builder.mdx +4 -4
- package/docs/api-reference/workflow-nest/workflow-controller.mdx +1 -1
- package/docs/api-reference/workflow-nest/workflow-module.mdx +4 -4
- package/docs/api-reference/workflow-next/with-workflow.mdx +16 -16
- package/docs/api-reference/workflow-nitro/index.mdx +6 -6
- package/docs/api-reference/workflow-nuxt/index.mdx +4 -4
- package/docs/api-reference/workflow-observability/hydrate-data.mdx +5 -5
- package/docs/api-reference/workflow-observability/hydrate-resource-io.mdx +4 -4
- package/docs/api-reference/workflow-observability/index.mdx +6 -8
- package/docs/api-reference/workflow-observability/observability-revivers.mdx +2 -2
- package/docs/api-reference/workflow-observability/parse-class-name.mdx +3 -3
- package/docs/api-reference/workflow-observability/parse-step-name.mdx +4 -4
- package/docs/api-reference/workflow-observability/parse-workflow-name.mdx +4 -4
- package/docs/api-reference/workflow-runtime/create-world.mdx +8 -8
- package/docs/api-reference/workflow-runtime/get-world-handlers.mdx +6 -6
- package/docs/api-reference/workflow-runtime/get-world.mdx +4 -4
- package/docs/api-reference/workflow-runtime/health-check.mdx +1 -1
- package/docs/api-reference/workflow-runtime/index.mdx +2 -4
- package/docs/api-reference/workflow-runtime/set-world.mdx +15 -13
- package/docs/api-reference/workflow-runtime/workflow-entrypoint.mdx +6 -5
- package/docs/api-reference/workflow-runtime/world/analytics.mdx +9 -9
- package/docs/api-reference/workflow-runtime/world/index.mdx +5 -3
- package/docs/api-reference/workflow-runtime/world/queue.mdx +11 -11
- package/docs/api-reference/workflow-runtime/world/storage.mdx +62 -28
- package/docs/api-reference/workflow-runtime/world/streams.mdx +7 -7
- package/docs/api-reference/workflow-serde/index.mdx +1 -1
- package/docs/api-reference/workflow-serde/workflow-deserialize.mdx +2 -2
- package/docs/api-reference/workflow-serde/workflow-serialize.mdx +7 -7
- package/docs/api-reference/workflow-sveltekit/workflow-plugin.mdx +3 -3
- package/docs/api-reference/workflow-vite/workflow.mdx +5 -5
- package/docs/changelog/attributes-mvp.mdx +39 -39
- package/docs/changelog/batched-event-writes.mdx +12 -12
- package/docs/changelog/eager-processing.mdx +63 -63
- package/docs/changelog/index.mdx +4 -3
- package/docs/changelog/lazy-event-creation.md +27 -27
- package/docs/changelog/lazy-hook-resume.mdx +51 -0
- package/docs/changelog/meta.json +1 -0
- package/docs/changelog/resilient-resume.mdx +13 -5
- package/docs/changelog/resilient-start.mdx +14 -14
- package/docs/changelog/step-message-ownership.mdx +47 -47
- package/docs/changelog/turbo-mode.md +20 -20
- package/docs/comparisons/index.mdx +13 -13
- package/docs/comparisons/workflow-sdk-vs-aws-agentcore.mdx +15 -15
- package/docs/comparisons/workflow-sdk-vs-aws-step-functions.mdx +12 -12
- package/docs/comparisons/workflow-sdk-vs-cloudflare-workflows.mdx +11 -11
- package/docs/comparisons/workflow-sdk-vs-inngest.mdx +19 -19
- package/docs/comparisons/workflow-sdk-vs-temporal.mdx +23 -23
- package/docs/comparisons/workflow-sdk-vs-trigger-dev.mdx +18 -17
- package/docs/configuration/build-and-diagnostics.mdx +5 -5
- package/docs/configuration/cli-and-web-ui.mdx +4 -4
- package/docs/configuration/runtime-tuning.mdx +87 -23
- package/docs/configuration/worlds.mdx +28 -14
- package/docs/cookbook/advanced/child-workflows.mdx +25 -25
- package/docs/cookbook/advanced/publishing-libraries.mdx +40 -40
- package/docs/cookbook/advanced/serializable-steps.mdx +21 -21
- package/docs/cookbook/advanced/upgrading-workflows.mdx +31 -31
- package/docs/cookbook/agent-patterns/agent-cancellation.mdx +20 -20
- package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +22 -22
- package/docs/cookbook/common-patterns/batching.mdx +14 -14
- package/docs/cookbook/common-patterns/idempotency.mdx +9 -9
- package/docs/cookbook/common-patterns/rate-limiting.mdx +3 -3
- package/docs/cookbook/common-patterns/saga.mdx +19 -19
- package/docs/cookbook/common-patterns/scheduling.mdx +23 -23
- package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +26 -26
- package/docs/cookbook/common-patterns/timeouts.mdx +23 -23
- package/docs/cookbook/common-patterns/webhooks.mdx +6 -6
- package/docs/cookbook/common-patterns/workflow-composition.mdx +19 -19
- package/docs/cookbook/index.mdx +22 -22
- package/docs/cookbook/integrations/ai-sdk.mdx +43 -41
- package/docs/cookbook/integrations/chat-sdk.mdx +34 -34
- package/docs/cookbook/integrations/sandbox.mdx +46 -46
- package/docs/deploying.mdx +15 -15
- package/docs/errors/abort-signal-timeout-in-workflow.mdx +12 -12
- package/docs/errors/corrupted-event-log.mdx +11 -11
- package/docs/errors/deployment-mismatch.mdx +14 -14
- package/docs/errors/fetch-in-workflow.mdx +8 -8
- package/docs/errors/hook-conflict.mdx +11 -11
- package/docs/errors/index.mdx +1 -1
- package/docs/errors/node-js-module-in-workflow.mdx +5 -5
- package/docs/errors/replay-divergence.mdx +2 -2
- package/docs/errors/runtime-decryption-failed.mdx +12 -12
- package/docs/errors/serialization-failed.mdx +40 -12
- package/docs/errors/start-invalid-workflow-function.mdx +5 -5
- package/docs/errors/step-executed-multiple-times.mdx +2 -2
- package/docs/errors/step-not-registered.mdx +5 -5
- package/docs/errors/timeout-in-workflow.mdx +8 -8
- package/docs/errors/webhook-invalid-respond-with-value.mdx +18 -18
- package/docs/errors/webhook-response-not-sent.mdx +16 -16
- package/docs/errors/workflow-not-registered.mdx +5 -5
- package/docs/foundations/cancellation.mdx +31 -31
- package/docs/foundations/errors-and-retries.mdx +42 -11
- package/docs/foundations/hooks.mdx +35 -35
- package/docs/foundations/idempotency.mdx +9 -9
- package/docs/foundations/serialization.mdx +21 -22
- package/docs/foundations/starting-workflows.mdx +36 -37
- package/docs/foundations/streaming.mdx +46 -41
- package/docs/foundations/versioning.mdx +3 -3
- package/docs/foundations/workflows-and-steps.mdx +9 -9
- package/docs/getting-started/astro.mdx +16 -16
- package/docs/getting-started/express.mdx +8 -8
- package/docs/getting-started/fastify.mdx +8 -8
- package/docs/getting-started/hono.mdx +8 -8
- package/docs/getting-started/nestjs.mdx +18 -17
- package/docs/getting-started/next.mdx +11 -11
- package/docs/getting-started/nitro.mdx +16 -16
- package/docs/getting-started/nuxt.mdx +8 -8
- package/docs/getting-started/python.mdx +4 -4
- package/docs/getting-started/react-router/v7.mdx +1 -1
- package/docs/getting-started/react-router/v8.mdx +1 -1
- package/docs/getting-started/sveltekit.mdx +14 -14
- package/docs/getting-started/tanstack-start.mdx +12 -12
- package/docs/getting-started/vite.mdx +8 -8
- package/docs/how-it-works/cancellation.mdx +62 -62
- package/docs/how-it-works/code-transform.mdx +66 -54
- package/docs/how-it-works/encryption.mdx +25 -21
- package/docs/how-it-works/event-sourcing.mdx +53 -35
- package/docs/how-it-works/framework-integrations.mdx +12 -12
- package/docs/how-it-works/understanding-directives.mdx +21 -21
- package/docs/internal/index.mdx +6 -6
- package/docs/internal/nitro-native-build.mdx +2 -2
- package/docs/internal/nitro-web-ui.mdx +4 -4
- package/docs/internal/serializable-abort-controller.mdx +7 -7
- package/docs/observability/attributes.mdx +3 -3
- package/docs/observability/index.mdx +14 -10
- package/docs/observability/tracing.mdx +10 -10
- package/docs/testing/index.mdx +33 -33
- package/docs/testing/server-based.mdx +10 -10
- package/docs/whats-new.mdx +185 -0
- package/package.json +12 -12
|
@@ -5,12 +5,10 @@ type: overview
|
|
|
5
5
|
summary: Explore runtime functions for starting workflows, inspecting runs, and managing hooks.
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
The `workflow/api` package provides runtime functions to inspect runs, start new runs, and manage hooks.
|
|
9
9
|
|
|
10
10
|
## Functions
|
|
11
11
|
|
|
12
|
-
The API package is for access and introspection of workflow data to inspect runs, start new runs, and manage hooks.
|
|
13
|
-
|
|
14
12
|
<Cards>
|
|
15
13
|
<Card href="/docs/api-reference/workflow-api/start" title="start()">
|
|
16
14
|
Start/enqueue a new workflow run.
|
|
@@ -30,5 +28,5 @@ The API package is for access and introspection of workflow data to inspect runs
|
|
|
30
28
|
</Cards>
|
|
31
29
|
|
|
32
30
|
<Callout type="info">
|
|
33
|
-
Looking for `getWorld()` and the World SDK? They are exported from `workflow/runtime
|
|
31
|
+
Looking for `getWorld()` and the World SDK? They are exported from `workflow/runtime`. See the [`workflow/runtime` reference](/docs/api-reference/workflow-runtime).
|
|
34
32
|
</Callout>
|
|
@@ -12,9 +12,9 @@ related:
|
|
|
12
12
|
|
|
13
13
|
Resumes a workflow run by sending a payload to a hook identified by its token.
|
|
14
14
|
|
|
15
|
-
It
|
|
15
|
+
It publishes a workflow invocation carrying the payload; the runtime creates the `hook_received` event and continues execution from it.
|
|
16
16
|
|
|
17
|
-
A Hook kept by `experimental_minRetention
|
|
17
|
+
`resumeHook()` throws `HookNotFoundError` when no hook holds the token. A run that has already ended cannot be resumed, including one whose Hook is kept by `experimental_minRetention`, but whether the call reports that depends on the path it takes: a resume dispatched without reading the run resolves and the ended state is only detected once the payload arrives, while one that reads the run, or that falls back to writing the event up front, throws `HookNotFoundError`. See [lazy hook resume](/docs/changelog/lazy-hook-resume).
|
|
18
18
|
|
|
19
19
|
<Callout type="warn">
|
|
20
20
|
`resumeHook` is a runtime function that must be called from outside a workflow function.
|
|
@@ -37,7 +37,7 @@ export async function POST(request: Request) {
|
|
|
37
37
|
}
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
## API
|
|
40
|
+
## API signature
|
|
41
41
|
|
|
42
42
|
### Parameters
|
|
43
43
|
|
|
@@ -50,7 +50,7 @@ showSections={["parameters"]}
|
|
|
50
50
|
|
|
51
51
|
### Returns
|
|
52
52
|
|
|
53
|
-
Returns a `Promise<ResumedHook
|
|
53
|
+
Returns a `Promise<ResumedHook>`, a `Hook` extended with an optional `resilientResume` flag. Resolving means the resume was accepted for delivery: the payload rides the workflow queue message and the runtime materializes the `hook_received` event from it before replaying (see the [lazy hook resume changelog](/docs/changelog/lazy-hook-resume)). `resilientResume` is retained for source compatibility and is no longer set by any path. The resolved hook:
|
|
54
54
|
|
|
55
55
|
<TSDoc
|
|
56
56
|
definition={`
|
|
@@ -61,7 +61,7 @@ showSections={["returns"]}
|
|
|
61
61
|
|
|
62
62
|
## Examples
|
|
63
63
|
|
|
64
|
-
### Basic API
|
|
64
|
+
### Basic API route
|
|
65
65
|
|
|
66
66
|
Using `resumeHook` in a basic API route to resume a hook:
|
|
67
67
|
|
|
@@ -84,7 +84,7 @@ export async function POST(request: Request) {
|
|
|
84
84
|
}
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
### With
|
|
87
|
+
### With type safety
|
|
88
88
|
|
|
89
89
|
Defining a payload type and using `resumeHook` to resume a hook with type safety:
|
|
90
90
|
|
|
@@ -112,7 +112,7 @@ export async function POST(request: Request) {
|
|
|
112
112
|
}
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
### Server
|
|
115
|
+
### Server action (Next.js)
|
|
116
116
|
|
|
117
117
|
Using `resumeHook` in Next.js server actions to resume a hook:
|
|
118
118
|
|
|
@@ -131,7 +131,7 @@ export async function approveRequest(token: string, approved: boolean) {
|
|
|
131
131
|
}
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
### Webhook
|
|
134
|
+
### Webhook handler
|
|
135
135
|
|
|
136
136
|
Using `resumeHook` in a generic webhook handler to resume a hook:
|
|
137
137
|
|
|
@@ -158,11 +158,11 @@ export async function POST(request: Request) {
|
|
|
158
158
|
}
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
### Resume or
|
|
161
|
+
### Resume or start
|
|
162
162
|
|
|
163
|
-
A common endpoint shape is "resume or start": one route that resumes the active workflow run for a business key if one exists, or starts a new run otherwise. This comes up when the workflow uses a deterministic hook token as its idempotency key
|
|
163
|
+
A common endpoint shape is "resume or start": one route that resumes the active workflow run for a business key if one exists, or starts a new run otherwise. This comes up when the workflow uses a deterministic hook token as its idempotency key, for example, one active run per order or conversation.
|
|
164
164
|
|
|
165
|
-
`resumeHook()` is the resume half of that flow. Try it first; if it throws `HookNotFoundError`, no active run owns the token yet, so start the workflow. One subtlety: `start()` returns before the new run executes and registers its hook, so you cannot resume immediately after starting. Retry the resume until the hook is registered
|
|
165
|
+
`resumeHook()` is the resume half of that flow. Try it first; if it throws `HookNotFoundError`, no active run owns the token yet, so start the workflow. One subtlety: `start()` returns before the new run executes and registers its hook, so you cannot resume immediately after starting. Retry the resume until the hook is registered: if you drop the payload and only start the workflow, the data from this request is lost.
|
|
166
166
|
|
|
167
167
|
```typescript lineNumbers
|
|
168
168
|
import { resumeHook, start } from "workflow/api";
|
|
@@ -213,9 +213,9 @@ export async function POST(request: Request) {
|
|
|
213
213
|
|
|
214
214
|
See [Run idempotency](/docs/foundations/idempotency#run-idempotency) for the full pattern, including how the workflow claims the token with `hook.getConflict()` and how concurrent starts converge on one active owner.
|
|
215
215
|
|
|
216
|
-
## Related
|
|
216
|
+
## Related functions
|
|
217
217
|
|
|
218
|
-
- [`getHookByToken()`](/docs/api-reference/workflow-api/get-hook-by-token)
|
|
219
|
-
- [`createHook()`](/docs/api-reference/workflow/create-hook)
|
|
220
|
-
- [`defineHook()`](/docs/api-reference/workflow/define-hook)
|
|
221
|
-
- [Idempotency](/docs/foundations/idempotency)
|
|
218
|
+
- [`getHookByToken()`](/docs/api-reference/workflow-api/get-hook-by-token): Get hook details before resuming.
|
|
219
|
+
- [`createHook()`](/docs/api-reference/workflow/create-hook): Create a hook in a workflow.
|
|
220
|
+
- [`defineHook()`](/docs/api-reference/workflow/define-hook): Type-safe hook helper.
|
|
221
|
+
- [Idempotency](/docs/foundations/idempotency): Deduplicate step side effects and workflow starts.
|
|
@@ -11,7 +11,7 @@ related:
|
|
|
11
11
|
|
|
12
12
|
Resumes a workflow run by sending an HTTP `Request` to a webhook identified by its token.
|
|
13
13
|
|
|
14
|
-
This function
|
|
14
|
+
This function publishes a workflow invocation carrying the request; the runtime creates the `hook_received` event from it and continues execution. It's designed to be called from API routes or server actions that receive external HTTP requests.
|
|
15
15
|
|
|
16
16
|
<Callout type="warn">
|
|
17
17
|
`resumeWebhook` is a runtime function that must be called from outside a workflow function.
|
|
@@ -37,7 +37,7 @@ export async function POST(request: Request) {
|
|
|
37
37
|
}
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
## API
|
|
40
|
+
## API signature
|
|
41
41
|
|
|
42
42
|
### Parameters
|
|
43
43
|
|
|
@@ -58,7 +58,7 @@ Returns a `Promise<Response>` that resolves to one of:
|
|
|
58
58
|
|
|
59
59
|
Throws [`HookNotFoundError`](/docs/api-reference/workflow-errors/hook-not-found-error) if the token does not match an active webhook.
|
|
60
60
|
|
|
61
|
-
## Usage
|
|
61
|
+
## Usage note
|
|
62
62
|
|
|
63
63
|
<Callout type="warn">
|
|
64
64
|
In most cases, you should not need to call `resumeWebhook()` directly. When you use `createWebhook()`, the framework automatically generates a webhook token and provides a public URL at `/.well-known/workflow/v1/webhook/:token`. External systems can send HTTP requests directly to that URL.
|
|
@@ -90,7 +90,7 @@ export async function POST(request: Request) {
|
|
|
90
90
|
}
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
## Related
|
|
93
|
+
## Related functions
|
|
94
94
|
|
|
95
95
|
- [`createWebhook()`](/docs/api-reference/workflow/create-webhook) - Create a webhook in a workflow
|
|
96
96
|
- [`resumeHook()`](/docs/api-reference/workflow-api/resume-hook) - Resume a hook with arbitrary payload
|
|
@@ -18,7 +18,7 @@ import { myWorkflow } from "./workflows/my-workflow";
|
|
|
18
18
|
const run = await start(myWorkflow); // [!code highlight]
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
## API
|
|
21
|
+
## API signature
|
|
22
22
|
|
|
23
23
|
### Parameters
|
|
24
24
|
|
|
@@ -50,24 +50,25 @@ showSections={["returns"]}
|
|
|
50
50
|
|
|
51
51
|
Learn more about [`WorkflowReadableStreamOptions`](/docs/api-reference/workflow-api/get-run#workflowreadablestreamoptions).
|
|
52
52
|
|
|
53
|
-
## Good to
|
|
53
|
+
## Good to know
|
|
54
54
|
|
|
55
|
-
*
|
|
56
|
-
* In v5,
|
|
55
|
+
* Use the `start()` function in runtime contexts to programmatically trigger workflow executions.
|
|
56
|
+
* In v5, you can also call `start()` directly from a workflow function to spawn a child run or continue work in a new run. See [Workflow Composition](/cookbook/common-patterns/workflow-composition) and [Versioning](/docs/foundations/versioning).
|
|
57
57
|
* This is different from calling workflow functions directly, which is the typical pattern in Next.js applications.
|
|
58
|
-
* The function returns immediately after enqueuing the workflow
|
|
59
|
-
* Each call to `start()` creates a new workflow run. If retried requests must route to one active workflow, have the workflow create a deterministic hook token and use [`getHookByToken()`](/docs/api-reference/workflow-api/get-hook-by-token) to reuse an already-registered active hook. The lookup is not atomic with `start()`, so concurrent callers can still create extra runs before the hook is registered
|
|
58
|
+
* The function returns immediately after enqueuing the workflow. It doesn't wait for the workflow to complete.
|
|
59
|
+
* Each call to `start()` creates a new workflow run. If retried requests must route to one active workflow, have the workflow create a deterministic hook token and use [`getHookByToken()`](/docs/api-reference/workflow-api/get-hook-by-token) to reuse an already-registered active hook. The lookup is not atomic with `start()`, so concurrent callers can still create extra runs before the hook is registered. Handle that race inside the workflow by checking `await hook.getConflict()` before duplicate-sensitive work. On a conflict, it resolves with the run that owns the token, so the duplicate can return the active owner to the caller. If duplicates must be rejected before a workflow body runs, keep a durable request record until native atomic start-and-hook registration exists. See [Idempotency](/docs/foundations/idempotency#run-idempotency).
|
|
60
60
|
* All arguments must be [serializable](/docs/foundations/serialization).
|
|
61
|
-
* When `deploymentId
|
|
61
|
+
* When you provide `deploymentId`, the argument types and return type become `unknown` because the workflow function's types may differ across deployments.
|
|
62
62
|
* `attributes` seeds plaintext run metadata as part of creation and requires a World implementing spec version 4 or later. Keys that start with `$` are reserved for framework and library code; framework-level callers can pass `allowReservedAttributes: true` to seed reserved keys, with the same semantics as the [`setAttributes`](/docs/api-reference/workflow/set-attributes) option of the same name.
|
|
63
|
+
* `region` pins the new run to a specific region on Worlds with a regional dimension. The [Vercel World](/worlds/vercel#explicit-region-selection) then serves the run's storage, queue dispatch, and streams from that region. When you omit `region`, the run is pinned to the region where it was created. Worlds without regions ignore the option.
|
|
63
64
|
|
|
64
65
|
<Callout type="info">
|
|
65
|
-
If `start()` throws `'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.`, the
|
|
66
|
+
If `start()` throws `'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.`, the compiler did not transform the passed function as a workflow. The two most common causes are a missing `"use workflow"` directive or missing framework integration. See [start-invalid-workflow-function](/docs/errors/start-invalid-workflow-function).
|
|
66
67
|
</Callout>
|
|
67
68
|
|
|
68
69
|
## Examples
|
|
69
70
|
|
|
70
|
-
### With
|
|
71
|
+
### With arguments
|
|
71
72
|
|
|
72
73
|
```typescript
|
|
73
74
|
import { start } from "workflow/api";
|
|
@@ -102,7 +103,7 @@ const run = await start(myWorkflow, ["arg1", "arg2"], { // [!code highlight]
|
|
|
102
103
|
```
|
|
103
104
|
|
|
104
105
|
<Callout type="info">
|
|
105
|
-
The `deploymentId` option is currently a Vercel-specific feature. Other Worlds may implement this option differently to match their own deployment runtimes, and the World spec may rename it from `deploymentId` to `version` in a future SDK version. On Vercel, `"latest"` resolves to the most recent deployment matching your current environment
|
|
106
|
+
The `deploymentId` option is currently a Vercel-specific feature. Other Worlds may implement this option differently to match their own deployment runtimes, and the World spec may rename it from `deploymentId` to `version` in a future SDK version. On Vercel, `"latest"` resolves to the most recent deployment matching your current environment: the same production target for production deployments, or the same git branch for preview deployments.
|
|
106
107
|
|
|
107
108
|
In Worlds without atomic, immutable deployments (such as local development or self-hosted Postgres), there is no notion of multiple deployments to resolve between, so `deploymentId: "latest"` has no effect: the SDK logs a warning and the run targets the current deployment. This means a workflow that opts into `"latest"` on Vercel still runs unchanged in local development.
|
|
108
109
|
</Callout>
|
|
@@ -110,13 +111,13 @@ In Worlds without atomic, immutable deployments (such as local development or se
|
|
|
110
111
|
<Callout type="warn">
|
|
111
112
|
When using `deploymentId: "latest"`, the workflow run will execute on a potentially different deployment than the one calling `start()`. Be mindful of forward and backward compatibility:
|
|
112
113
|
|
|
113
|
-
- **Workflow identity**: The
|
|
114
|
-
- **Input and output compatibility**: The arguments passed to `start()
|
|
114
|
+
- **Workflow identity**: The function name and file path determine the workflow ID. If the latest deployment has renamed the workflow function or moved it to a different directory, the workflow ID will no longer match and the run will fail to start.
|
|
115
|
+
- **Input and output compatibility**: The calling deployment serializes the arguments passed to `start()`, and the target deployment deserializes them. Similarly, the target deployment serializes the workflow's return value, and the caller deserializes it. If the workflow's expected arguments or return type have changed (for example, added required fields, removed fields, or changed types), the run may fail or behave unexpectedly. Ensure that input and output schemas remain backward-compatible across deployments.
|
|
115
116
|
</Callout>
|
|
116
117
|
|
|
117
|
-
### Inside a
|
|
118
|
+
### Inside a workflow function
|
|
118
119
|
|
|
119
|
-
`start()`
|
|
120
|
+
Call `start()` directly from a workflow function to spawn a child run. It is step-backed, so the spawn records a deterministic step boundary in the parent's event log.
|
|
120
121
|
|
|
121
122
|
```typescript
|
|
122
123
|
import { start } from "workflow/api";
|
|
@@ -136,5 +137,5 @@ The returned `Run` object is fully functional inside a workflow. Each property a
|
|
|
136
137
|
</Callout>
|
|
137
138
|
|
|
138
139
|
<Callout type="warn">
|
|
139
|
-
`returnValue` polls the child run every second and holds the polling step's worker slot open for as long as the child takes to finish. For long-running children, spawn without awaiting `returnValue` and have the child resume a [hook](/docs/foundations/hooks) when it completes
|
|
140
|
+
`returnValue` polls the child run every second and holds the polling step's worker slot open for as long as the child takes to finish. For long-running children, spawn without awaiting `returnValue` and have the child resume a [hook](/docs/foundations/hooks) when it completes. See the [`startAndWait()` pattern](/cookbook/advanced/child-workflows).
|
|
140
141
|
</Callout>
|
|
@@ -24,9 +24,9 @@ export default defineConfig({
|
|
|
24
24
|
});
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
The integration registers the workflow Vite transform plugins during `astro:config:setup` and builds the workflow bundles
|
|
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
28
|
|
|
29
|
-
## API
|
|
29
|
+
## API signature
|
|
30
30
|
|
|
31
31
|
### Parameters
|
|
32
32
|
|
|
@@ -38,7 +38,7 @@ The integration registers the workflow Vite transform plugins during `astro:conf
|
|
|
38
38
|
|
|
39
39
|
| Option | Type | Default | Description |
|
|
40
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
|
|
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, which helps stay under the Vercel 250 MB function size limit). Set it explicitly, or use the `WORKFLOW_SOURCEMAP` environment variable, to override in either environment. |
|
|
42
42
|
|
|
43
43
|
### Returns
|
|
44
44
|
|
|
@@ -26,12 +26,12 @@ try {
|
|
|
26
26
|
await world.events.create(runId, event);
|
|
27
27
|
} catch (error) {
|
|
28
28
|
if (EntityConflictError.is(error)) { // [!code highlight]
|
|
29
|
-
// Event already exists
|
|
29
|
+
// Event already exists, safe to ignore during replay
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
## API
|
|
34
|
+
## API signature
|
|
35
35
|
|
|
36
36
|
### Properties
|
|
37
37
|
|
|
@@ -44,11 +44,11 @@ interface EntityConflictError {
|
|
|
44
44
|
export default EntityConflictError;`}
|
|
45
45
|
/>
|
|
46
46
|
|
|
47
|
-
### Static
|
|
47
|
+
### Static methods
|
|
48
48
|
|
|
49
49
|
#### `EntityConflictError.is(value)`
|
|
50
50
|
|
|
51
|
-
Type-safe check for `EntityConflictError` instances. Preferred over `instanceof` because it works across module boundaries and
|
|
51
|
+
Type-safe check for `EntityConflictError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
|
|
52
52
|
|
|
53
53
|
```typescript
|
|
54
54
|
import { EntityConflictError } from "workflow/errors"
|
|
@@ -9,7 +9,7 @@ related:
|
|
|
9
9
|
- /docs/errors/hook-conflict
|
|
10
10
|
---
|
|
11
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
|
|
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
13
|
|
|
14
14
|
```typescript lineNumbers
|
|
15
15
|
import { HookConflictError } from "workflow/errors"
|
|
@@ -27,7 +27,7 @@ try {
|
|
|
27
27
|
}
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
## API
|
|
30
|
+
## API signature
|
|
31
31
|
|
|
32
32
|
### Properties
|
|
33
33
|
|
|
@@ -44,11 +44,11 @@ interface HookConflictError {
|
|
|
44
44
|
export default HookConflictError;`}
|
|
45
45
|
/>
|
|
46
46
|
|
|
47
|
-
### Static
|
|
47
|
+
### Static methods
|
|
48
48
|
|
|
49
49
|
#### `HookConflictError.is(value)`
|
|
50
50
|
|
|
51
|
-
Type-safe check for `HookConflictError` instances. Preferred over `instanceof` because it works across module boundaries and
|
|
51
|
+
Type-safe check for `HookConflictError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
|
|
52
52
|
|
|
53
53
|
```typescript
|
|
54
54
|
import { HookConflictError } from "workflow/errors"
|
|
@@ -10,9 +10,9 @@ related:
|
|
|
10
10
|
|
|
11
11
|
`HookNotFoundError` is thrown when calling `resumeHook()` or `resumeWebhook()` with a token that does not match any active hook. This typically happens when:
|
|
12
12
|
|
|
13
|
-
- The hook
|
|
14
|
-
- The hook was already consumed and disposed
|
|
15
|
-
- The workflow has not started yet, so the hook does not exist
|
|
13
|
+
- The hook's time to live (TTL) has expired.
|
|
14
|
+
- The hook was already consumed and disposed.
|
|
15
|
+
- The workflow has not started yet, so the hook does not exist.
|
|
16
16
|
|
|
17
17
|
```typescript lineNumbers
|
|
18
18
|
import { HookNotFoundError } from "workflow/errors"
|
|
@@ -29,7 +29,7 @@ try {
|
|
|
29
29
|
}
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
## API
|
|
32
|
+
## API signature
|
|
33
33
|
|
|
34
34
|
### Properties
|
|
35
35
|
|
|
@@ -44,11 +44,11 @@ interface HookNotFoundError {
|
|
|
44
44
|
export default HookNotFoundError;`}
|
|
45
45
|
/>
|
|
46
46
|
|
|
47
|
-
### Static
|
|
47
|
+
### Static methods
|
|
48
48
|
|
|
49
49
|
#### `HookNotFoundError.is(value)`
|
|
50
50
|
|
|
51
|
-
Type-safe check for `HookNotFoundError` instances. Preferred over `instanceof` because it works across module boundaries and
|
|
51
|
+
Type-safe check for `HookNotFoundError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
|
|
52
52
|
|
|
53
53
|
```typescript
|
|
54
54
|
import { HookNotFoundError } from "workflow/errors"
|
|
@@ -66,7 +66,7 @@ if (HookNotFoundError.is(error)) {
|
|
|
66
66
|
A common pattern for idempotent workflows is to try resuming a hook, and if it doesn't exist yet, start a new workflow run with the input data.
|
|
67
67
|
|
|
68
68
|
<Callout>
|
|
69
|
-
This "resume or start" pattern is not atomic
|
|
69
|
+
This "resume or start" pattern is not atomic: there is a small window where a race condition is possible. A better native approach is being worked on, but this pattern works well for many use cases.
|
|
70
70
|
</Callout>
|
|
71
71
|
|
|
72
72
|
```typescript lineNumbers
|
|
@@ -80,7 +80,7 @@ async function handleIncomingEvent(token: string, data: unknown) {
|
|
|
80
80
|
await resumeHook(token, data);
|
|
81
81
|
} catch (error) {
|
|
82
82
|
if (HookNotFoundError.is(error)) { // [!code highlight]
|
|
83
|
-
// Hook doesn't exist yet
|
|
83
|
+
// Hook doesn't exist yet, so start a new workflow run
|
|
84
84
|
await startWorkflow("processEvent", data); // [!code highlight]
|
|
85
85
|
} else {
|
|
86
86
|
throw error;
|
|
@@ -11,7 +11,7 @@ API reference for the error classes exported from the `workflow/errors` package.
|
|
|
11
11
|
|
|
12
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
13
|
|
|
14
|
-
## Base
|
|
14
|
+
## Base classes
|
|
15
15
|
|
|
16
16
|
<Cards>
|
|
17
17
|
<Card href="/docs/api-reference/workflow-errors/workflow-error" title="WorkflowError">
|
|
@@ -22,7 +22,7 @@ All errors extend [`WorkflowError`](/docs/api-reference/workflow-errors/workflow
|
|
|
22
22
|
</Card>
|
|
23
23
|
</Cards>
|
|
24
24
|
|
|
25
|
-
## Registration
|
|
25
|
+
## Registration errors
|
|
26
26
|
|
|
27
27
|
<Cards>
|
|
28
28
|
<Card href="/docs/api-reference/workflow-errors/workflow-not-registered-error" title="WorkflowNotRegisteredError">
|
|
@@ -33,7 +33,7 @@ All errors extend [`WorkflowError`](/docs/api-reference/workflow-errors/workflow
|
|
|
33
33
|
</Card>
|
|
34
34
|
</Cards>
|
|
35
35
|
|
|
36
|
-
## Run
|
|
36
|
+
## Run errors
|
|
37
37
|
|
|
38
38
|
<Cards>
|
|
39
39
|
<Card href="/docs/api-reference/workflow-errors/workflow-run-not-found-error" title="WorkflowRunNotFoundError">
|
|
@@ -43,7 +43,7 @@ All errors extend [`WorkflowError`](/docs/api-reference/workflow-errors/workflow
|
|
|
43
43
|
Thrown when awaiting the return value of a failed workflow run.
|
|
44
44
|
</Card>
|
|
45
45
|
<Card href="/docs/api-reference/workflow-errors/workflow-run-cancelled-error" title="WorkflowRunCancelledError">
|
|
46
|
-
Thrown when awaiting the return value of a
|
|
46
|
+
Thrown when awaiting the return value of a canceled workflow run.
|
|
47
47
|
</Card>
|
|
48
48
|
<Card href="/docs/api-reference/workflow-errors/workflow-run-not-completed-error" title="WorkflowRunNotCompletedError">
|
|
49
49
|
Thrown when requesting the result of a workflow run that has not completed yet.
|
|
@@ -59,7 +59,7 @@ All errors extend [`WorkflowError`](/docs/api-reference/workflow-errors/workflow
|
|
|
59
59
|
</Card>
|
|
60
60
|
</Cards>
|
|
61
61
|
|
|
62
|
-
## Hook
|
|
62
|
+
## Hook errors
|
|
63
63
|
|
|
64
64
|
<Cards>
|
|
65
65
|
<Card href="/docs/api-reference/workflow-errors/hook-not-found-error" title="HookNotFoundError">
|
|
@@ -70,7 +70,7 @@ All errors extend [`WorkflowError`](/docs/api-reference/workflow-errors/workflow
|
|
|
70
70
|
</Card>
|
|
71
71
|
</Cards>
|
|
72
72
|
|
|
73
|
-
## Backend
|
|
73
|
+
## Backend errors
|
|
74
74
|
|
|
75
75
|
<Cards>
|
|
76
76
|
<Card href="/docs/api-reference/workflow-errors/throttle-error" title="ThrottleError">
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: PreconditionFailedError
|
|
3
|
-
description:
|
|
3
|
+
description: World implementations throw this error when they reject an event creation because the client's event-log snapshot is stale.
|
|
4
4
|
type: reference
|
|
5
|
-
summary: Catch PreconditionFailedError when a
|
|
5
|
+
summary: Catch PreconditionFailedError when a World rejects an event creation made from a stale event-log snapshot.
|
|
6
6
|
related:
|
|
7
7
|
- /docs/api-reference/workflow-errors/workflow-world-error
|
|
8
8
|
- /docs/api-reference/workflow-errors/entity-conflict-error
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
`PreconditionFailedError`
|
|
11
|
+
World implementations throw `PreconditionFailedError` when they reject an event creation because the client's event-log snapshot is stale: the log already held more events than the position the creation named. It corresponds to HTTP 412 Precondition Failed semantics.
|
|
12
12
|
|
|
13
|
-
No
|
|
13
|
+
No World in this repository throws it. A stale replay does not need to be refused: its log is a prefix rather than a prefix with a hole in it, replay is deterministic on a prefix, and the write it makes next comes back carrying the events it was pushed past (see [Stale reads](/docs/configuration/runtime-tuning#stale-reads-and-why-nothing-has-to-be-rejected)). The error and the runtime's handling of it remain for a World that would rather refuse than report. Such a World allocates positions somewhere other than the commit, so it cannot report a gap reliably. Event creations that carry no position are never rejected with it.
|
|
14
14
|
|
|
15
|
-
A
|
|
15
|
+
A World rejects only on evidence and accepts the creation whenever it cannot decide. This error always means the snapshot was stale, but not receiving it does not prove the snapshot was current.
|
|
16
16
|
|
|
17
17
|
<Callout>
|
|
18
|
-
The Workflow runtime handles this error
|
|
18
|
+
The Workflow runtime handles this error by restarting the replay in the same invocation from a corrected event log. It re-invokes the run for a fresh replay only after spending its in-process restart budget. 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
19
|
</Callout>
|
|
20
20
|
|
|
21
|
-
A
|
|
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. This is optional, and the runtime falls back to a full reload when the details are absent or unusable.
|
|
22
22
|
|
|
23
23
|
```typescript lineNumbers
|
|
24
24
|
import { PreconditionFailedError } from "workflow/errors"
|
|
@@ -35,7 +35,7 @@ try {
|
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
## API
|
|
38
|
+
## API signature
|
|
39
39
|
|
|
40
40
|
### Properties
|
|
41
41
|
|
|
@@ -52,7 +52,7 @@ interface PreconditionFailedError {
|
|
|
52
52
|
export default PreconditionFailedError;`}
|
|
53
53
|
/>
|
|
54
54
|
|
|
55
|
-
### Static
|
|
55
|
+
### Static methods
|
|
56
56
|
|
|
57
57
|
#### `PreconditionFailedError.is(value)`
|
|
58
58
|
|
|
@@ -29,7 +29,7 @@ try {
|
|
|
29
29
|
}
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
## API
|
|
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
|
|
45
|
+
### Static methods
|
|
46
46
|
|
|
47
47
|
#### `RunExpiredError.is(value)`
|
|
48
48
|
|
|
@@ -7,7 +7,7 @@ related:
|
|
|
7
7
|
- /docs/foundations/versioning
|
|
8
8
|
---
|
|
9
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
|
|
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
11
|
|
|
12
12
|
```typescript lineNumbers
|
|
13
13
|
import { RunNotSupportedError } from "workflow/errors"
|
|
@@ -25,7 +25,7 @@ try {
|
|
|
25
25
|
}
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
## API
|
|
28
|
+
## API signature
|
|
29
29
|
|
|
30
30
|
### Properties
|
|
31
31
|
|
|
@@ -42,11 +42,11 @@ interface RunNotSupportedError {
|
|
|
42
42
|
export default RunNotSupportedError;`}
|
|
43
43
|
/>
|
|
44
44
|
|
|
45
|
-
### Static
|
|
45
|
+
### Static methods
|
|
46
46
|
|
|
47
47
|
#### `RunNotSupportedError.is(value)`
|
|
48
48
|
|
|
49
|
-
Type-safe check for `RunNotSupportedError` instances. Preferred over `instanceof` because it works across module boundaries and
|
|
49
|
+
Type-safe check for `RunNotSupportedError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
|
|
50
50
|
|
|
51
51
|
```typescript
|
|
52
52
|
import { RunNotSupportedError } from "workflow/errors"
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
49
|
+
### Static methods
|
|
50
50
|
|
|
51
51
|
#### `TooEarlyError.is(value)`
|
|
52
52
|
|
|
@@ -17,7 +17,7 @@ const error = new WorkflowError("something went wrong", {
|
|
|
17
17
|
});
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
## API
|
|
20
|
+
## API signature
|
|
21
21
|
|
|
22
22
|
### Properties
|
|
23
23
|
|
|
@@ -32,14 +32,14 @@ interface WorkflowError {
|
|
|
32
32
|
export default WorkflowError;`}
|
|
33
33
|
/>
|
|
34
34
|
|
|
35
|
-
### Static
|
|
35
|
+
### Static methods
|
|
36
36
|
|
|
37
37
|
#### `WorkflowError.is(value)`
|
|
38
38
|
|
|
39
|
-
Type-safe check for `WorkflowError` instances. Preferred over `instanceof` because it works across module boundaries and
|
|
39
|
+
Type-safe check for `WorkflowError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
|
|
40
40
|
|
|
41
41
|
<Callout type="warn">
|
|
42
|
-
`WorkflowError.is()` matches only direct `WorkflowError` instances
|
|
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
43
|
</Callout>
|
|
44
44
|
|
|
45
45
|
```typescript
|