workflow 5.0.0-beta.5 → 5.0.0-beta.50
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 +68 -23
- 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 +3 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +5 -7
- 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 +20 -3
- package/dist/internal/builtins.d.ts.map +1 -1
- package/dist/internal/builtins.js +68 -4
- 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 +4 -1
- package/docs/ai/chat-session-modeling.mdx +29 -26
- package/docs/ai/defining-tools.mdx +6 -7
- package/docs/ai/human-in-the-loop.mdx +11 -11
- package/docs/ai/index.mdx +50 -45
- package/docs/ai/message-queueing.mdx +16 -16
- package/docs/ai/meta.json +1 -0
- package/docs/ai/resumable-streams.mdx +40 -28
- package/docs/ai/sleep-and-delays.mdx +10 -10
- package/docs/ai/streaming-updates-from-tools.mdx +6 -6
- package/docs/api-reference/index.mdx +24 -0
- package/docs/api-reference/meta.json +8 -0
- package/docs/api-reference/vitest/index.mdx +9 -15
- package/docs/api-reference/workflow/create-hook.mdx +89 -10
- package/docs/api-reference/workflow/create-webhook.mdx +16 -15
- package/docs/api-reference/workflow/define-hook.mdx +35 -33
- package/docs/api-reference/workflow/fatal-error.mdx +30 -8
- package/docs/api-reference/workflow/fetch.mdx +14 -10
- 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 +4 -1
- package/docs/api-reference/workflow/retryable-error.mdx +1 -1
- package/docs/api-reference/workflow/set-attributes.mdx +61 -0
- package/docs/api-reference/workflow/sleep.mdx +4 -4
- package/docs/api-reference/workflow-ai/durable-agent.mdx +48 -86
- package/docs/api-reference/workflow-ai/index.mdx +3 -3
- package/docs/api-reference/workflow-ai/workflow-chat-transport.mdx +67 -24
- package/docs/api-reference/workflow-api/get-hook-by-token.mdx +26 -12
- package/docs/api-reference/workflow-api/get-run.mdx +43 -8
- package/docs/api-reference/workflow-api/index.mdx +6 -10
- package/docs/api-reference/workflow-api/resume-hook.mdx +73 -12
- package/docs/api-reference/workflow-api/resume-webhook.mdx +11 -9
- package/docs/api-reference/workflow-api/start.mdx +60 -13
- 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/entity-conflict-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/hook-conflict-error.mdx +60 -0
- package/docs/api-reference/workflow-errors/hook-not-found-error.mdx +8 -8
- 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-expired-error.mdx +2 -2
- package/docs/api-reference/workflow-errors/run-not-supported-error.mdx +58 -0
- 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 +52 -0
- 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 +58 -0
- package/docs/api-reference/workflow-errors/workflow-run-not-found-error.mdx +4 -4
- package/docs/api-reference/workflow-errors/workflow-runtime-error.mdx +58 -0
- package/docs/api-reference/workflow-errors/workflow-world-error.mdx +8 -8
- package/docs/api-reference/workflow-globals.mdx +14 -10
- 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 +39 -17
- 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 +62 -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 +11 -14
- package/docs/api-reference/workflow-runtime/health-check.mdx +50 -0
- package/docs/api-reference/workflow-runtime/index.mdx +41 -0
- package/docs/api-reference/workflow-runtime/meta.json +12 -0
- package/docs/api-reference/workflow-runtime/set-world.mdx +51 -0
- package/docs/api-reference/workflow-runtime/workflow-entrypoint.mdx +43 -0
- package/docs/api-reference/workflow-runtime/world/analytics.mdx +315 -0
- package/docs/api-reference/workflow-runtime/world/index.mdx +60 -0
- package/docs/api-reference/workflow-runtime/world/meta.json +4 -0
- package/docs/api-reference/workflow-runtime/world/queue.mdx +88 -0
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/storage.mdx +98 -34
- package/docs/api-reference/{workflow-api → workflow-runtime}/world/streams.mdx +8 -8
- package/docs/api-reference/workflow-serde/index.mdx +1 -2
- package/docs/api-reference/workflow-serde/workflow-deserialize.mdx +3 -4
- package/docs/api-reference/workflow-serde/workflow-serialize.mdx +8 -8
- 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/batched-event-writes.mdx +79 -0
- package/docs/changelog/eager-processing.mdx +110 -436
- package/docs/changelog/index.mdx +4 -2
- package/docs/changelog/lazy-event-creation.md +127 -0
- package/docs/changelog/lazy-hook-resume.mdx +78 -0
- package/docs/changelog/meta.json +11 -1
- package/docs/changelog/resilient-resume.mdx +32 -0
- package/docs/changelog/resilient-start.mdx +33 -285
- 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 +104 -0
- package/docs/configuration/build-and-diagnostics.mdx +70 -0
- package/docs/configuration/cli-and-web-ui.mdx +241 -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 +376 -0
- package/docs/configuration/worlds.mdx +313 -0
- package/docs/cookbook/advanced/child-workflows.mdx +211 -264
- package/docs/cookbook/advanced/meta.json +6 -1
- package/docs/cookbook/advanced/publishing-libraries.mdx +65 -56
- package/docs/cookbook/advanced/serializable-steps.mdx +28 -20
- package/docs/cookbook/advanced/upgrading-workflows.mdx +199 -0
- package/docs/cookbook/agent-patterns/agent-cancellation.mdx +27 -19
- package/docs/cookbook/agent-patterns/durable-agent.mdx +14 -142
- package/docs/cookbook/agent-patterns/human-in-the-loop.mdx +30 -22
- package/docs/cookbook/common-patterns/batching.mdx +18 -14
- package/docs/cookbook/common-patterns/idempotency.mdx +41 -53
- package/docs/cookbook/common-patterns/rate-limiting.mdx +8 -4
- package/docs/cookbook/common-patterns/saga.mdx +23 -19
- package/docs/cookbook/common-patterns/scheduling.mdx +34 -22
- package/docs/cookbook/common-patterns/sequential-and-parallel.mdx +29 -25
- package/docs/cookbook/common-patterns/timeouts.mdx +26 -21
- package/docs/cookbook/common-patterns/webhooks.mdx +10 -6
- package/docs/cookbook/common-patterns/workflow-composition.mdx +30 -27
- package/docs/cookbook/index.mdx +22 -21
- package/docs/cookbook/integrations/ai-sdk.mdx +85 -47
- package/docs/cookbook/integrations/chat-sdk.mdx +50 -33
- package/docs/cookbook/integrations/sandbox.mdx +62 -45
- package/docs/deploying.mdx +95 -0
- package/docs/errors/abort-signal-timeout-in-workflow.mdx +16 -12
- package/docs/errors/corrupted-event-log.mdx +29 -18
- package/docs/errors/deployment-mismatch.mdx +71 -0
- package/docs/errors/fetch-in-workflow.mdx +11 -7
- package/docs/errors/hook-conflict.mdx +69 -13
- package/docs/errors/index.mdx +2 -36
- package/docs/errors/node-js-module-in-workflow.mdx +9 -5
- package/docs/errors/replay-divergence.mdx +27 -0
- package/docs/errors/run-expired.mdx +85 -0
- package/docs/errors/runtime-decryption-failed.mdx +77 -0
- package/docs/errors/serialization-failed.mdx +44 -12
- package/docs/errors/start-invalid-workflow-function.mdx +9 -5
- package/docs/errors/step-executed-multiple-times.mdx +23 -0
- package/docs/errors/step-not-registered.mdx +6 -6
- package/docs/errors/timeout-in-workflow.mdx +12 -8
- package/docs/errors/webhook-invalid-respond-with-value.mdx +18 -18
- package/docs/errors/webhook-response-not-sent.mdx +20 -16
- package/docs/errors/workflow-not-registered.mdx +5 -5
- package/docs/foundations/cancellation.mdx +31 -32
- package/docs/foundations/errors-and-retries.mdx +42 -11
- package/docs/foundations/hooks.mdx +64 -35
- package/docs/foundations/idempotency.mdx +244 -12
- package/docs/foundations/index.mdx +1 -23
- package/docs/foundations/meta.json +2 -1
- package/docs/foundations/serialization.mdx +21 -22
- package/docs/foundations/starting-workflows.mdx +106 -30
- package/docs/foundations/streaming.mdx +107 -59
- package/docs/foundations/versioning.mdx +263 -0
- package/docs/foundations/workflows-and-steps.mdx +9 -9
- package/docs/getting-started/astro.mdx +22 -18
- package/docs/getting-started/express.mdx +15 -11
- package/docs/getting-started/fastify.mdx +15 -11
- package/docs/getting-started/hono.mdx +15 -11
- package/docs/getting-started/index.mdx +10 -3
- package/docs/getting-started/meta.json +3 -1
- package/docs/getting-started/nestjs.mdx +87 -20
- package/docs/getting-started/next.mdx +22 -16
- package/docs/getting-started/nitro.mdx +22 -18
- package/docs/getting-started/nuxt.mdx +15 -11
- package/docs/getting-started/python.mdx +135 -40
- 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 +20 -16
- package/docs/getting-started/tanstack-start.mdx +17 -13
- package/docs/getting-started/vite.mdx +15 -11
- package/docs/how-it-works/cancellation.mdx +63 -63
- package/docs/how-it-works/code-transform.mdx +83 -67
- package/docs/how-it-works/encryption.mdx +30 -26
- package/docs/how-it-works/event-sourcing.mdx +98 -34
- package/docs/how-it-works/framework-integrations.mdx +96 -337
- package/docs/how-it-works/understanding-directives.mdx +22 -22
- package/docs/internal/index.mdx +6 -4
- package/docs/internal/meta.json +6 -1
- 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 +7 -7
- package/docs/meta.json +3 -2
- package/docs/observability/attributes.mdx +134 -0
- package/docs/observability/index.mdx +32 -10
- package/docs/observability/meta.json +1 -1
- package/docs/observability/retention.mdx +93 -0
- package/docs/observability/tracing.mdx +124 -0
- package/docs/testing/index.mdx +36 -36
- package/docs/testing/server-based.mdx +10 -10
- package/docs/whats-new.mdx +186 -0
- package/package.json +17 -14
- package/docs/api-reference/workflow-api/world/index.mdx +0 -58
- package/docs/api-reference/workflow-api/world/meta.json +0 -4
- package/docs/api-reference/workflow-api/world/observability.mdx +0 -164
- package/docs/api-reference/workflow-api/world/queue.mdx +0 -86
- package/docs/deploying/building-a-world.mdx +0 -251
- package/docs/deploying/index.mdx +0 -95
- 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 -224
- 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,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 canceled 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: World implementations throw this error when they reject an event creation 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
|
+
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
|
+
|
|
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
|
+
|
|
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
|
+
|
|
17
|
+
<Callout>
|
|
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
|
+
</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. This 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
|
+
```
|
|
@@ -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
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: RunNotSupportedError
|
|
3
|
+
description: Thrown when a workflow run requires a newer workflow spec version than the installed SDK supports.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Catch RunNotSupportedError when stored run data requires a newer workflow package version.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/foundations/versioning
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
`RunNotSupportedError` is thrown when reading a workflow run whose data was written with a newer workflow spec version than the running SDK supports. This typically means the run was created by a newer version of the `workflow` package. Upgrade the package to process it.
|
|
11
|
+
|
|
12
|
+
```typescript lineNumbers
|
|
13
|
+
import { RunNotSupportedError } from "workflow/errors"
|
|
14
|
+
declare function readRun(runId: string): Promise<unknown>; // @setup
|
|
15
|
+
declare const runId: string; // @setup
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
await readRun(runId);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
if (RunNotSupportedError.is(error)) { // [!code highlight]
|
|
21
|
+
console.error(
|
|
22
|
+
`Run requires spec v${error.runSpecVersion}, world supports v${error.worldSpecVersion}`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## API signature
|
|
29
|
+
|
|
30
|
+
### Properties
|
|
31
|
+
|
|
32
|
+
<TSDoc
|
|
33
|
+
definition={`
|
|
34
|
+
interface RunNotSupportedError {
|
|
35
|
+
/** The spec version the run's stored data requires. */
|
|
36
|
+
runSpecVersion: number;
|
|
37
|
+
/** The spec version the current World supports. */
|
|
38
|
+
worldSpecVersion: number;
|
|
39
|
+
/** The error message. */
|
|
40
|
+
message: string;
|
|
41
|
+
}
|
|
42
|
+
export default RunNotSupportedError;`}
|
|
43
|
+
/>
|
|
44
|
+
|
|
45
|
+
### Static methods
|
|
46
|
+
|
|
47
|
+
#### `RunNotSupportedError.is(value)`
|
|
48
|
+
|
|
49
|
+
Type-safe check for `RunNotSupportedError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { RunNotSupportedError } from "workflow/errors"
|
|
53
|
+
declare const error: unknown; // @setup
|
|
54
|
+
|
|
55
|
+
if (RunNotSupportedError.is(error)) {
|
|
56
|
+
// error is typed as RunNotSupportedError
|
|
57
|
+
}
|
|
58
|
+
```
|
|
@@ -8,7 +8,7 @@ related:
|
|
|
8
8
|
- /docs/api-reference/workflow-errors/workflow-not-registered-error
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
`StepNotRegisteredError` is thrown when the runtime tries to execute a step function that is not registered in the current deployment. This is an infrastructure error
|
|
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
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: WorkflowError
|
|
3
|
+
description: Base class for all workflow error types.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: All errors thrown by the Workflow SDK extend WorkflowError.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/foundations/errors-and-retries
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
`WorkflowError` is the base class that all Workflow SDK error types extend, such as [`WorkflowRunFailedError`](/docs/api-reference/workflow-errors/workflow-run-failed-error) and [`HookNotFoundError`](/docs/api-reference/workflow-errors/hook-not-found-error). It extends `Error` with an optional `cause` and, for some subclasses, a link to the relevant error documentation appended to the message.
|
|
11
|
+
|
|
12
|
+
```typescript lineNumbers
|
|
13
|
+
import { WorkflowError } from "workflow/errors"
|
|
14
|
+
|
|
15
|
+
const error = new WorkflowError("something went wrong", {
|
|
16
|
+
cause: new Error("underlying cause"),
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## API signature
|
|
21
|
+
|
|
22
|
+
### Properties
|
|
23
|
+
|
|
24
|
+
<TSDoc
|
|
25
|
+
definition={`
|
|
26
|
+
interface WorkflowError {
|
|
27
|
+
/** The error message. */
|
|
28
|
+
message: string;
|
|
29
|
+
/** The underlying cause, when provided. */
|
|
30
|
+
cause?: unknown;
|
|
31
|
+
}
|
|
32
|
+
export default WorkflowError;`}
|
|
33
|
+
/>
|
|
34
|
+
|
|
35
|
+
### Static methods
|
|
36
|
+
|
|
37
|
+
#### `WorkflowError.is(value)`
|
|
38
|
+
|
|
39
|
+
Type-safe check for `WorkflowError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
|
|
40
|
+
|
|
41
|
+
<Callout type="warn">
|
|
42
|
+
`WorkflowError.is()` matches only direct `WorkflowError` instances, not subclasses, which override the error name it checks. To handle a specific error type, use that subclass's own `.is()` method (e.g. `WorkflowRunFailedError.is(error)`).
|
|
43
|
+
</Callout>
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { WorkflowError } from "workflow/errors"
|
|
47
|
+
declare const error: unknown; // @setup
|
|
48
|
+
|
|
49
|
+
if (WorkflowError.is(error)) {
|
|
50
|
+
// error is typed as WorkflowError
|
|
51
|
+
}
|
|
52
|
+
```
|
|
@@ -8,7 +8,7 @@ related:
|
|
|
8
8
|
- /docs/api-reference/workflow-errors/step-not-registered-error
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
`WorkflowNotRegisteredError` is thrown when the runtime tries to execute a workflow function that is not registered in the current deployment. This is an infrastructure error
|
|
11
|
+
`WorkflowNotRegisteredError` is thrown when the runtime tries to execute a workflow function that is not registered in the current deployment. This is an infrastructure error, not a user code error. It typically means a run was started against a deployment that does not have this workflow (e.g., the workflow was renamed or moved), or there was a build/bundling issue.
|
|
12
12
|
|
|
13
13
|
When this error occurs, the run fails with a `RUNTIME_ERROR` error code.
|
|
14
14
|
|
|
@@ -21,7 +21,7 @@ if (WorkflowNotRegisteredError.is(error)) { // [!code highlight]
|
|
|
21
21
|
}
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
## API
|
|
24
|
+
## API signature
|
|
25
25
|
|
|
26
26
|
### Properties
|
|
27
27
|
|
|
@@ -36,14 +36,14 @@ interface WorkflowNotRegisteredError {
|
|
|
36
36
|
export default WorkflowNotRegisteredError;`}
|
|
37
37
|
/>
|
|
38
38
|
|
|
39
|
-
### Static
|
|
39
|
+
### Static methods
|
|
40
40
|
|
|
41
41
|
#### `WorkflowNotRegisteredError.is(value)`
|
|
42
42
|
|
|
43
|
-
Type-safe check for `WorkflowNotRegisteredError` instances. Preferred over `instanceof` because it works across module boundaries and
|
|
43
|
+
Type-safe check for `WorkflowNotRegisteredError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
|
|
44
44
|
|
|
45
45
|
<Callout>
|
|
46
|
-
The `.is()` method works in server-side Node.js code (API routes, middleware). When checking the error from `run.returnValue`, use `WorkflowRunFailedError.is()` and inspect `error.cause
|
|
46
|
+
The `.is()` method works in server-side Node.js code (API routes, middleware). When checking the error from `run.returnValue`, use `WorkflowRunFailedError.is()` and inspect `error.cause`: the underlying error is deserialized from the event log.
|
|
47
47
|
</Callout>
|
|
48
48
|
|
|
49
49
|
```typescript
|
|
@@ -54,4 +54,3 @@ if (WorkflowNotRegisteredError.is(error)) {
|
|
|
54
54
|
// error is typed as WorkflowNotRegisteredError
|
|
55
55
|
}
|
|
56
56
|
```
|
|
57
|
-
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: WorkflowRunCancelledError
|
|
3
|
-
description: Thrown when awaiting the return value of a
|
|
3
|
+
description: Thrown when awaiting the return value of a canceled workflow run.
|
|
4
4
|
type: reference
|
|
5
|
-
summary: Catch WorkflowRunCancelledError when awaiting run.returnValue on a run that was
|
|
5
|
+
summary: Catch WorkflowRunCancelledError when awaiting run.returnValue on a run that was canceled.
|
|
6
6
|
related:
|
|
7
7
|
- /docs/api-reference/workflow-errors/workflow-run-failed-error
|
|
8
8
|
- /docs/api-reference/workflow-errors/workflow-run-not-found-error
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
`WorkflowRunCancelledError` is thrown when awaiting `run.returnValue` on a workflow run that was explicitly
|
|
11
|
+
`WorkflowRunCancelledError` is thrown when awaiting `run.returnValue` on a workflow run that was explicitly canceled via `run.cancel()`. Canceled runs do not produce a return value.
|
|
12
12
|
|
|
13
13
|
You can check for cancellation before awaiting by inspecting `run.status`.
|
|
14
14
|
|
|
@@ -25,14 +25,14 @@ try {
|
|
|
25
25
|
}
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
## API
|
|
28
|
+
## API signature
|
|
29
29
|
|
|
30
30
|
### Properties
|
|
31
31
|
|
|
32
32
|
<TSDoc
|
|
33
33
|
definition={`
|
|
34
34
|
interface WorkflowRunCancelledError {
|
|
35
|
-
/** The ID of the
|
|
35
|
+
/** The ID of the canceled run. */
|
|
36
36
|
runId: string;
|
|
37
37
|
/** The error message. */
|
|
38
38
|
message: string;
|
|
@@ -40,7 +40,7 @@ interface WorkflowRunCancelledError {
|
|
|
40
40
|
export default WorkflowRunCancelledError;`}
|
|
41
41
|
/>
|
|
42
42
|
|
|
43
|
-
### Static
|
|
43
|
+
### Static methods
|
|
44
44
|
|
|
45
45
|
#### `WorkflowRunCancelledError.is(value)`
|
|
46
46
|
|
|
@@ -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 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
|
|
14
|
+
The `cause` property holds the original thrown value, hydrated through the workflow serialization pipeline so its type identity (e.g. `FatalError`, `RetryableError`, custom `Error` subclasses), `cause` chain, and custom properties are preserved. Because any JavaScript value can be thrown, `cause` is typed as `unknown`, so narrow it with `instanceof Error` (or a more specific check) before accessing fields like `message`. The high-level error classification is exposed as the top-level `errorCode` property.
|
|
15
15
|
|
|
16
16
|
```typescript lineNumbers
|
|
17
17
|
import { WorkflowRunFailedError } from "workflow/errors"
|
|
@@ -31,7 +31,7 @@ try {
|
|
|
31
31
|
}
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
## API
|
|
34
|
+
## API signature
|
|
35
35
|
|
|
36
36
|
### Properties
|
|
37
37
|
|
|
@@ -45,7 +45,7 @@ interface WorkflowRunFailedError {
|
|
|
45
45
|
* the workflow serialization pipeline. Preserves the original type identity
|
|
46
46
|
* (Error subclasses, FatalError, custom classes with WORKFLOW_SERIALIZE,
|
|
47
47
|
* etc.) and custom properties. Typed as \`unknown\` because any value can
|
|
48
|
-
* be thrown
|
|
48
|
+
* be thrown, so narrow with \`instanceof Error\` before accessing fields.
|
|
49
49
|
*/
|
|
50
50
|
cause: unknown;
|
|
51
51
|
/** The high-level error category (e.g. \`USER_ERROR\`, \`RUNTIME_ERROR\`). */
|
|
@@ -56,11 +56,11 @@ interface WorkflowRunFailedError {
|
|
|
56
56
|
export default WorkflowRunFailedError;`}
|
|
57
57
|
/>
|
|
58
58
|
|
|
59
|
-
### Static
|
|
59
|
+
### Static methods
|
|
60
60
|
|
|
61
61
|
#### `WorkflowRunFailedError.is(value)`
|
|
62
62
|
|
|
63
|
-
Type-safe check for `WorkflowRunFailedError` instances. Preferred over `instanceof` because it works across module boundaries and
|
|
63
|
+
Type-safe check for `WorkflowRunFailedError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
66
|
import { WorkflowRunFailedError } from "workflow/errors"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: WorkflowRunNotCompletedError
|
|
3
|
+
description: Thrown when requesting the result of a workflow run that has not completed yet.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Catch WorkflowRunNotCompletedError when reading the return value of a run that is still pending or running.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/api-reference/workflow-api/get-run
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
`WorkflowRunNotCompletedError` is thrown when requesting the result of a workflow run that has not completed yet. The run's current status (for example `pending` or `running`) is available on the error.
|
|
11
|
+
|
|
12
|
+
[`run.returnValue()`](/docs/api-reference/workflow-api/get-run) handles this error internally (it polls until the run completes), so you will mainly encounter it when building custom polling logic on lower-level APIs.
|
|
13
|
+
|
|
14
|
+
```typescript lineNumbers
|
|
15
|
+
import { WorkflowRunNotCompletedError } from "workflow/errors"
|
|
16
|
+
declare function readRunResult(runId: string): Promise<unknown>; // @setup
|
|
17
|
+
declare const runId: string; // @setup
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const result = await readRunResult(runId);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (WorkflowRunNotCompletedError.is(error)) { // [!code highlight]
|
|
23
|
+
console.log(`Run ${error.runId} is still ${error.status}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## API signature
|
|
29
|
+
|
|
30
|
+
### Properties
|
|
31
|
+
|
|
32
|
+
<TSDoc
|
|
33
|
+
definition={`
|
|
34
|
+
interface WorkflowRunNotCompletedError {
|
|
35
|
+
/** The workflow run ID. */
|
|
36
|
+
runId: string;
|
|
37
|
+
/** The run's status at the time of the error (e.g. "pending", "running"). */
|
|
38
|
+
status: string;
|
|
39
|
+
/** The error message. */
|
|
40
|
+
message: string;
|
|
41
|
+
}
|
|
42
|
+
export default WorkflowRunNotCompletedError;`}
|
|
43
|
+
/>
|
|
44
|
+
|
|
45
|
+
### Static methods
|
|
46
|
+
|
|
47
|
+
#### `WorkflowRunNotCompletedError.is(value)`
|
|
48
|
+
|
|
49
|
+
Type-safe check for `WorkflowRunNotCompletedError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { WorkflowRunNotCompletedError } from "workflow/errors"
|
|
53
|
+
declare const error: unknown; // @setup
|
|
54
|
+
|
|
55
|
+
if (WorkflowRunNotCompletedError.is(error)) {
|
|
56
|
+
// error is typed as WorkflowRunNotCompletedError
|
|
57
|
+
}
|
|
58
|
+
```
|
|
@@ -10,7 +10,7 @@ related:
|
|
|
10
10
|
|
|
11
11
|
`WorkflowRunNotFoundError` is thrown when performing operations on a workflow run that does not exist. This includes calling methods like `run.status`, `run.cancel()`, or awaiting `run.returnValue` on a run whose ID does not match any known workflow run.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`getRun(id)` itself is synchronous and will not throw. Subsequent operations on the run object raise the error when they discover the run is missing.
|
|
14
14
|
|
|
15
15
|
```typescript lineNumbers
|
|
16
16
|
import { WorkflowRunNotFoundError } from "workflow/errors"
|
|
@@ -25,7 +25,7 @@ try {
|
|
|
25
25
|
}
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
## API
|
|
28
|
+
## API signature
|
|
29
29
|
|
|
30
30
|
### Properties
|
|
31
31
|
|
|
@@ -40,11 +40,11 @@ interface WorkflowRunNotFoundError {
|
|
|
40
40
|
export default WorkflowRunNotFoundError;`}
|
|
41
41
|
/>
|
|
42
42
|
|
|
43
|
-
### Static
|
|
43
|
+
### Static methods
|
|
44
44
|
|
|
45
45
|
#### `WorkflowRunNotFoundError.is(value)`
|
|
46
46
|
|
|
47
|
-
Type-safe check for `WorkflowRunNotFoundError` instances. Preferred over `instanceof` because it works across module boundaries and
|
|
47
|
+
Type-safe check for `WorkflowRunNotFoundError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
|
|
48
48
|
|
|
49
49
|
```typescript
|
|
50
50
|
import { WorkflowRunNotFoundError } from "workflow/errors"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: WorkflowRuntimeError
|
|
3
|
+
description: Thrown when the workflow runtime encounters an execution error, such as serialization failures or timeouts.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Catch WorkflowRuntimeError for runtime-level failures like unserializable values or workflow timeouts.
|
|
6
|
+
related:
|
|
7
|
+
- /docs/foundations/serialization
|
|
8
|
+
- /docs/foundations/errors-and-retries
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
`WorkflowRuntimeError` is thrown when the workflow runtime encounters an error executing a workflow. Common causes include:
|
|
12
|
+
|
|
13
|
+
- Values crossing the workflow/step boundary that cannot be serialized
|
|
14
|
+
- Workflow execution timeouts
|
|
15
|
+
- Invalid runtime state, such as misconfigured streams
|
|
16
|
+
|
|
17
|
+
```typescript lineNumbers
|
|
18
|
+
import { WorkflowRuntimeError } from "workflow/errors"
|
|
19
|
+
declare function runWorkflowOperation(): Promise<void>; // @setup
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
await runWorkflowOperation();
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (WorkflowRuntimeError.is(error)) { // [!code highlight]
|
|
25
|
+
console.error("Workflow runtime error:", error.message);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## API signature
|
|
31
|
+
|
|
32
|
+
### Properties
|
|
33
|
+
|
|
34
|
+
<TSDoc
|
|
35
|
+
definition={`
|
|
36
|
+
interface WorkflowRuntimeError {
|
|
37
|
+
/** The error message. */
|
|
38
|
+
message: string;
|
|
39
|
+
/** The underlying cause, when provided. */
|
|
40
|
+
cause?: unknown;
|
|
41
|
+
}
|
|
42
|
+
export default WorkflowRuntimeError;`}
|
|
43
|
+
/>
|
|
44
|
+
|
|
45
|
+
### Static methods
|
|
46
|
+
|
|
47
|
+
#### `WorkflowRuntimeError.is(value)`
|
|
48
|
+
|
|
49
|
+
Type-safe check for `WorkflowRuntimeError` instances. Preferred over `instanceof` because it works across module boundaries and VM contexts.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { WorkflowRuntimeError } from "workflow/errors"
|
|
53
|
+
declare const error: unknown; // @setup
|
|
54
|
+
|
|
55
|
+
if (WorkflowRuntimeError.is(error)) {
|
|
56
|
+
// error is typed as WorkflowRuntimeError
|
|
57
|
+
}
|
|
58
|
+
```
|