@workflow/core 5.0.0-beta.9 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/dist/attribute-changes.d.ts +4 -5
- package/dist/attribute-changes.d.ts.map +1 -1
- package/dist/attribute-changes.js +12 -4
- package/dist/capabilities.d.ts +35 -2
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +74 -5
- package/dist/capture-stack.d.ts +1 -1
- package/dist/capture-stack.js +2 -2
- package/dist/class-serialization.d.ts +32 -0
- package/dist/class-serialization.d.ts.map +1 -1
- package/dist/class-serialization.js +37 -1
- package/dist/classify-error.d.ts +15 -0
- package/dist/classify-error.d.ts.map +1 -1
- package/dist/classify-error.js +72 -4
- package/dist/context-violation-error.d.ts +5 -5
- package/dist/context-violation-error.d.ts.map +1 -1
- package/dist/context-violation-error.js +8 -6
- package/dist/create-hook.d.ts +109 -7
- package/dist/create-hook.d.ts.map +1 -1
- package/dist/create-hook.js +1 -1
- package/dist/define-hook.js +2 -2
- package/dist/describe-error.d.ts +7 -7
- package/dist/describe-error.d.ts.map +1 -1
- package/dist/describe-error.js +46 -7
- package/dist/encryption.d.ts +32 -4
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +85 -10
- package/dist/events-consumer.d.ts +300 -0
- package/dist/events-consumer.d.ts.map +1 -1
- package/dist/events-consumer.js +672 -42
- package/dist/flushable-stream.d.ts +97 -1
- package/dist/flushable-stream.d.ts.map +1 -1
- package/dist/flushable-stream.js +286 -10
- package/dist/global.d.ts +38 -2
- package/dist/global.d.ts.map +1 -1
- package/dist/global.js +21 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/log-format.d.ts +6 -2
- package/dist/log-format.d.ts.map +1 -1
- package/dist/log-format.js +60 -15
- package/dist/logger.d.ts +1 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +10 -6
- package/dist/private.d.ts +258 -9
- package/dist/private.d.ts.map +1 -1
- package/dist/private.js +640 -7
- package/dist/replay-divergence.d.ts +25 -0
- package/dist/replay-divergence.d.ts.map +1 -0
- package/dist/replay-divergence.js +61 -0
- package/dist/replay-payload-cache.d.ts +64 -0
- package/dist/replay-payload-cache.d.ts.map +1 -0
- package/dist/replay-payload-cache.js +158 -0
- package/dist/runtime/compute-instance.d.ts +13 -0
- package/dist/runtime/compute-instance.d.ts.map +1 -0
- package/dist/runtime/compute-instance.js +14 -0
- package/dist/runtime/constants.d.ts +298 -5
- package/dist/runtime/constants.d.ts.map +1 -1
- package/dist/runtime/constants.js +500 -17
- package/dist/runtime/count-step-started-events.d.ts +52 -0
- package/dist/runtime/count-step-started-events.d.ts.map +1 -0
- package/dist/runtime/count-step-started-events.js +72 -0
- package/dist/runtime/deployment-guard.d.ts +100 -0
- package/dist/runtime/deployment-guard.d.ts.map +1 -0
- package/dist/runtime/deployment-guard.js +159 -0
- package/dist/runtime/dynamic-workflow.d.ts +148 -0
- package/dist/runtime/dynamic-workflow.d.ts.map +1 -0
- package/dist/runtime/dynamic-workflow.js +290 -0
- package/dist/runtime/get-port-lazy.d.ts +15 -0
- package/dist/runtime/get-port-lazy.d.ts.map +1 -1
- package/dist/runtime/get-port-lazy.js +75 -6
- package/dist/runtime/get-world-lazy.d.ts +5 -14
- package/dist/runtime/get-world-lazy.d.ts.map +1 -1
- package/dist/runtime/get-world-lazy.js +19 -29
- package/dist/runtime/helpers.d.ts +445 -29
- package/dist/runtime/helpers.d.ts.map +1 -1
- package/dist/runtime/helpers.js +717 -62
- package/dist/runtime/hook-wake.d.ts +122 -0
- package/dist/runtime/hook-wake.d.ts.map +1 -0
- package/dist/runtime/hook-wake.js +225 -0
- package/dist/runtime/invocations.d.ts +35 -0
- package/dist/runtime/invocations.d.ts.map +1 -0
- package/dist/runtime/invocations.js +172 -0
- package/dist/runtime/lifecycle-hooks.d.ts +93 -0
- package/dist/runtime/lifecycle-hooks.d.ts.map +1 -0
- package/dist/runtime/lifecycle-hooks.js +178 -0
- package/dist/runtime/open-hook-wait-state.d.ts +55 -0
- package/dist/runtime/open-hook-wait-state.d.ts.map +1 -0
- package/dist/runtime/open-hook-wait-state.js +93 -0
- package/dist/runtime/quickjs-assets.generated.d.ts +14 -0
- package/dist/runtime/quickjs-assets.generated.d.ts.map +1 -0
- package/dist/runtime/quickjs-assets.generated.js +30 -0
- package/dist/runtime/quickjs-entrypoint.d.ts +158 -0
- package/dist/runtime/quickjs-entrypoint.d.ts.map +1 -0
- package/dist/runtime/quickjs-entrypoint.js +1939 -0
- package/dist/runtime/quickjs-log-view.d.ts +129 -0
- package/dist/runtime/quickjs-log-view.d.ts.map +1 -0
- package/dist/runtime/quickjs-log-view.js +229 -0
- package/dist/runtime/quickjs-runtime.d.ts +247 -0
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -0
- package/dist/runtime/quickjs-runtime.js +2599 -0
- package/dist/runtime/quickjs-serde.d.ts +107 -0
- package/dist/runtime/quickjs-serde.d.ts.map +1 -0
- package/dist/runtime/quickjs-serde.js +2234 -0
- package/dist/runtime/replay-budget.d.ts +17 -18
- package/dist/runtime/replay-budget.d.ts.map +1 -1
- package/dist/runtime/replay-budget.js +33 -81
- package/dist/runtime/replay-recovery-reporter.d.ts +36 -0
- package/dist/runtime/replay-recovery-reporter.d.ts.map +1 -0
- package/dist/runtime/replay-recovery-reporter.js +64 -0
- package/dist/runtime/resume-hook.d.ts +93 -8
- package/dist/runtime/resume-hook.d.ts.map +1 -1
- package/dist/runtime/resume-hook.js +709 -110
- package/dist/runtime/resume-latency.d.ts +150 -0
- package/dist/runtime/resume-latency.d.ts.map +1 -0
- package/dist/runtime/resume-latency.js +155 -0
- package/dist/runtime/run-id-time.d.ts +19 -0
- package/dist/runtime/run-id-time.d.ts.map +1 -0
- package/dist/runtime/run-id-time.js +42 -0
- package/dist/runtime/run-spec-version.d.ts +16 -0
- package/dist/runtime/run-spec-version.d.ts.map +1 -0
- package/dist/runtime/run-spec-version.js +19 -0
- package/dist/runtime/run.d.ts +72 -7
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +295 -58
- package/dist/runtime/runs.d.ts +54 -3
- package/dist/runtime/runs.d.ts.map +1 -1
- package/dist/runtime/runs.js +148 -21
- package/dist/runtime/start.d.ts +164 -3
- package/dist/runtime/start.d.ts.map +1 -1
- package/dist/runtime/start.js +700 -78
- package/dist/runtime/step-executor.d.ts +186 -5
- package/dist/runtime/step-executor.d.ts.map +1 -1
- package/dist/runtime/step-executor.js +756 -123
- package/dist/runtime/step-latency.d.ts +221 -0
- package/dist/runtime/step-latency.d.ts.map +1 -0
- package/dist/runtime/step-latency.js +215 -0
- package/dist/runtime/step-ownership.d.ts +72 -0
- package/dist/runtime/step-ownership.d.ts.map +1 -0
- package/dist/runtime/step-ownership.js +114 -0
- package/dist/runtime/step-single-flight.d.ts +12 -0
- package/dist/runtime/step-single-flight.d.ts.map +1 -0
- package/dist/runtime/step-single-flight.js +71 -0
- package/dist/runtime/suspension-handler.d.ts +279 -10
- package/dist/runtime/suspension-handler.d.ts.map +1 -1
- package/dist/runtime/suspension-handler.js +1442 -169
- package/dist/runtime/unserializable-step.d.ts +34 -0
- package/dist/runtime/unserializable-step.d.ts.map +1 -0
- package/dist/runtime/unserializable-step.js +52 -0
- package/dist/runtime/vm-mode.d.ts +44 -0
- package/dist/runtime/vm-mode.d.ts.map +1 -0
- package/dist/runtime/vm-mode.js +62 -0
- package/dist/runtime/vm-serde-bundle.generated.d.ts +14 -0
- package/dist/runtime/vm-serde-bundle.generated.d.ts.map +1 -0
- package/dist/runtime/vm-serde-bundle.generated.js +16 -0
- package/dist/runtime/wait-continuation.d.ts +106 -0
- package/dist/runtime/wait-continuation.d.ts.map +1 -0
- package/dist/runtime/wait-continuation.js +136 -0
- package/dist/runtime/wait-until.d.ts +18 -0
- package/dist/runtime/wait-until.d.ts.map +1 -0
- package/dist/runtime/wait-until.js +42 -0
- package/dist/runtime/world-compatibility.d.ts +32 -0
- package/dist/runtime/world-compatibility.d.ts.map +1 -0
- package/dist/runtime/world-compatibility.js +44 -0
- package/dist/runtime/world-init.d.ts +17 -42
- package/dist/runtime/world-init.d.ts.map +1 -1
- package/dist/runtime/world-init.js +18 -43
- package/dist/runtime/world.d.ts +14 -2
- package/dist/runtime/world.d.ts.map +1 -1
- package/dist/runtime/world.js +75 -19
- package/dist/runtime.d.ts +11 -7
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +4111 -446
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +1 -1
- package/dist/sealed-box.d.ts +167 -0
- package/dist/sealed-box.d.ts.map +1 -0
- package/dist/sealed-box.js +571 -0
- package/dist/serialization/client.d.ts +3 -3
- package/dist/serialization/client.d.ts.map +1 -1
- package/dist/serialization/client.js +8 -4
- package/dist/serialization/codec-devalue-vm.d.ts +16 -0
- package/dist/serialization/codec-devalue-vm.d.ts.map +1 -0
- package/dist/serialization/codec-devalue-vm.js +148 -0
- package/dist/serialization/codec-devalue.d.ts +1 -1
- package/dist/serialization/codec-devalue.d.ts.map +1 -1
- package/dist/serialization/codec-devalue.js +24 -6
- package/dist/serialization/codec.d.ts +37 -2
- package/dist/serialization/codec.d.ts.map +1 -1
- package/dist/serialization/codec.js +2 -2
- package/dist/serialization/compression.d.ts +105 -0
- package/dist/serialization/compression.d.ts.map +1 -0
- package/dist/serialization/compression.js +261 -0
- package/dist/serialization/encryption.d.ts +119 -17
- package/dist/serialization/encryption.d.ts.map +1 -1
- package/dist/serialization/encryption.js +152 -17
- package/dist/serialization/errors.d.ts +13 -0
- package/dist/serialization/errors.d.ts.map +1 -1
- package/dist/serialization/errors.js +20 -2
- package/dist/serialization/format.d.ts +6 -6
- package/dist/serialization/format.js +7 -7
- package/dist/serialization/hardened.d.ts +156 -0
- package/dist/serialization/hardened.d.ts.map +1 -0
- package/dist/serialization/hardened.js +538 -0
- package/dist/serialization/index.d.ts +10 -8
- package/dist/serialization/index.d.ts.map +1 -1
- package/dist/serialization/index.js +10 -8
- package/dist/serialization/reducers/class-vm.d.ts +20 -0
- package/dist/serialization/reducers/class-vm.d.ts.map +1 -0
- package/dist/serialization/reducers/class-vm.js +77 -0
- package/dist/serialization/reducers/class.d.ts.map +1 -1
- package/dist/serialization/reducers/class.js +11 -6
- package/dist/serialization/reducers/common-vm.d.ts +15 -0
- package/dist/serialization/reducers/common-vm.d.ts.map +1 -0
- package/dist/serialization/reducers/common-vm.js +661 -0
- package/dist/serialization/reducers/common.d.ts +1 -1
- package/dist/serialization/reducers/common.d.ts.map +1 -1
- package/dist/serialization/reducers/common.js +227 -66
- package/dist/serialization/reducers/step-function-vm.d.ts +44 -0
- package/dist/serialization/reducers/step-function-vm.d.ts.map +1 -0
- package/dist/serialization/reducers/step-function-vm.js +97 -0
- package/dist/serialization/reducers/step-function.d.ts.map +1 -1
- package/dist/serialization/reducers/step-function.js +25 -9
- package/dist/serialization/step.d.ts +4 -4
- package/dist/serialization/step.d.ts.map +1 -1
- package/dist/serialization/step.js +9 -5
- package/dist/serialization/types.d.ts +75 -1
- package/dist/serialization/types.d.ts.map +1 -1
- package/dist/serialization/types.js +15 -1
- package/dist/serialization/workflow-vm.d.ts +29 -0
- package/dist/serialization/workflow-vm.d.ts.map +1 -0
- package/dist/serialization/workflow-vm.js +74 -0
- package/dist/serialization-format.d.ts +64 -8
- package/dist/serialization-format.d.ts.map +1 -1
- package/dist/serialization-format.js +239 -73
- package/dist/serialization.d.ts +319 -34
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +1961 -321
- package/dist/set-attributes.d.ts +7 -7
- package/dist/set-attributes.d.ts.map +1 -1
- package/dist/set-attributes.js +42 -21
- package/dist/source-map.d.ts +25 -0
- package/dist/source-map.d.ts.map +1 -1
- package/dist/source-map.js +113 -7
- package/dist/step/context-storage.d.ts +50 -3
- package/dist/step/context-storage.d.ts.map +1 -1
- package/dist/step/context-storage.js +7 -5
- package/dist/step/writable-stream.d.ts +3 -3
- package/dist/step/writable-stream.d.ts.map +1 -1
- package/dist/step/writable-stream.js +53 -19
- package/dist/step.d.ts.map +1 -1
- package/dist/step.js +142 -28
- package/dist/symbols.d.ts +35 -1
- package/dist/symbols.d.ts.map +1 -1
- package/dist/symbols.js +36 -2
- package/dist/telemetry/semantic-conventions.d.ts +481 -2
- package/dist/telemetry/semantic-conventions.d.ts.map +1 -1
- package/dist/telemetry/semantic-conventions.js +349 -3
- package/dist/telemetry.d.ts +91 -0
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +244 -17
- package/dist/test-support/orchestrator-context.d.ts +25 -0
- package/dist/test-support/orchestrator-context.d.ts.map +1 -0
- package/dist/test-support/orchestrator-context.js +107 -0
- package/dist/types.d.ts +23 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +76 -1
- package/dist/util.d.ts +0 -5
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +1 -15
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +2 -2
- package/dist/vm/index.d.ts.map +1 -1
- package/dist/vm/index.js +84 -14
- package/dist/vm/script-cache.d.ts +26 -0
- package/dist/vm/script-cache.d.ts.map +1 -0
- package/dist/vm/script-cache.js +131 -0
- package/dist/vm/uint8array-base64.js +1 -1
- package/dist/workflow/abort-controller.d.ts +2 -2
- package/dist/workflow/abort-controller.d.ts.map +1 -1
- package/dist/workflow/abort-controller.js +75 -21
- package/dist/workflow/attribute-dispatcher.d.ts +6 -0
- package/dist/workflow/attribute-dispatcher.d.ts.map +1 -0
- package/dist/workflow/attribute-dispatcher.js +65 -0
- package/dist/workflow/create-hook.d.ts.map +1 -1
- package/dist/workflow/create-hook.js +24 -3
- package/dist/workflow/get-workflow-metadata.js +2 -2
- package/dist/workflow/hook.d.ts.map +1 -1
- package/dist/workflow/hook.js +403 -53
- package/dist/workflow/index.d.ts +1 -1
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +2 -2
- package/dist/workflow/set-attributes.d.ts +19 -21
- package/dist/workflow/set-attributes.d.ts.map +1 -1
- package/dist/workflow/set-attributes.js +23 -25
- package/dist/workflow/sleep.d.ts.map +1 -1
- package/dist/workflow/sleep.js +42 -13
- package/dist/workflow/world-init-stub.d.ts +3 -3
- package/dist/workflow/world-init-stub.js +4 -4
- package/dist/workflow.d.ts +89 -3
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +920 -568
- package/docs/api-reference/create-hook.mdx +166 -10
- package/docs/api-reference/create-webhook.mdx +16 -15
- package/docs/api-reference/define-hook.mdx +37 -33
- package/docs/api-reference/fatal-error.mdx +30 -8
- package/docs/api-reference/fetch.mdx +14 -10
- package/docs/api-reference/get-step-metadata.mdx +2 -2
- package/docs/api-reference/get-workflow-metadata.mdx +3 -3
- package/docs/api-reference/get-writable.mdx +7 -7
- package/docs/api-reference/index.mdx +3 -3
- package/docs/api-reference/retryable-error.mdx +1 -1
- package/docs/api-reference/set-attributes.mdx +63 -0
- package/docs/api-reference/sleep.mdx +4 -4
- package/docs/foundations/cancellation.mdx +31 -32
- package/docs/foundations/errors-and-retries.mdx +54 -11
- package/docs/foundations/hooks.mdx +98 -35
- package/docs/foundations/idempotency.mdx +267 -12
- package/docs/foundations/index.mdx +1 -26
- package/docs/foundations/serialization.mdx +22 -22
- package/docs/foundations/starting-workflows.mdx +104 -30
- package/docs/foundations/streaming.mdx +108 -60
- package/docs/foundations/versioning.mdx +4 -4
- package/docs/foundations/workflows-and-steps.mdx +9 -9
- package/docs/how-it-works/cancellation.mdx +63 -63
- package/docs/how-it-works/code-transform.mdx +82 -66
- package/docs/how-it-works/encryption.mdx +30 -26
- package/docs/how-it-works/event-sourcing.mdx +132 -35
- package/docs/how-it-works/framework-integrations.mdx +96 -337
- package/docs/how-it-works/understanding-directives.mdx +22 -22
- package/package.json +29 -15
- package/dist/runtime/step-handler.d.ts +0 -2
- package/dist/runtime/step-handler.d.ts.map +0 -1
- package/dist/runtime/step-handler.js +0 -779
- package/docs/api-reference/experimental-set-attributes.mdx +0 -63
|
@@ -47,7 +47,7 @@ async function writeToStream(writable: WritableStream) {
|
|
|
47
47
|
}
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
## API
|
|
50
|
+
## API signature
|
|
51
51
|
|
|
52
52
|
### Parameters
|
|
53
53
|
|
|
@@ -69,7 +69,7 @@ export default getWritable;`}
|
|
|
69
69
|
|
|
70
70
|
Returns a `WritableStream<W>` where `W` is the type of data you plan to write to the stream.
|
|
71
71
|
|
|
72
|
-
## Good to
|
|
72
|
+
## Good to know
|
|
73
73
|
|
|
74
74
|
- **Workflow functions can only obtain the stream** - Call `getWritable()` in a workflow to get the stream reference, but you cannot call methods like `getWriter()`, `write()`, or `close()` directly in the workflow context.
|
|
75
75
|
- **Step functions can interact with streams** - Steps can receive the stream as an argument or call `getWritable()` directly, and they can freely interact with it (write, close, etc.).
|
|
@@ -81,9 +81,9 @@ Returns a `WritableStream<W>` where `W` is the type of data you plan to write to
|
|
|
81
81
|
|
|
82
82
|
## Examples
|
|
83
83
|
|
|
84
|
-
### Basic
|
|
84
|
+
### Basic text streaming
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
This example streams text data:
|
|
87
87
|
|
|
88
88
|
```typescript lineNumbers
|
|
89
89
|
import { sleep, getWritable } from "workflow";
|
|
@@ -118,7 +118,7 @@ async function stepCloseOutputStream(writable: WritableStream) {
|
|
|
118
118
|
}
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
### Calling `getWritable()`
|
|
121
|
+
### Calling `getWritable()` inside steps
|
|
122
122
|
|
|
123
123
|
You can also call `getWritable()` directly inside step functions without passing it as a parameter:
|
|
124
124
|
|
|
@@ -157,7 +157,7 @@ async function stepCloseOutputStreamInside() {
|
|
|
157
157
|
}
|
|
158
158
|
```
|
|
159
159
|
|
|
160
|
-
### Using
|
|
160
|
+
### Using namespaced streams in steps
|
|
161
161
|
|
|
162
162
|
You can also use namespaced streams when calling `getWritable()` from steps:
|
|
163
163
|
|
|
@@ -201,7 +201,7 @@ async function closeStreams() {
|
|
|
201
201
|
}
|
|
202
202
|
```
|
|
203
203
|
|
|
204
|
-
### Advanced
|
|
204
|
+
### Advanced chat streaming
|
|
205
205
|
|
|
206
206
|
Here's a more complex example showing how you might stream AI chat responses:
|
|
207
207
|
|
|
@@ -47,12 +47,12 @@ Workflow SDK contains the following functions you can use inside your workflow f
|
|
|
47
47
|
<Card href="/docs/api-reference/workflow/get-writable" title="getWritable()">
|
|
48
48
|
Access the current workflow run's default stream.
|
|
49
49
|
</Card>
|
|
50
|
-
<Card href="/docs/api-reference/workflow/
|
|
51
|
-
Attach
|
|
50
|
+
<Card href="/docs/api-reference/workflow/set-attributes" title="setAttributes()">
|
|
51
|
+
Attach string metadata to the current workflow run.
|
|
52
52
|
</Card>
|
|
53
53
|
</Cards>
|
|
54
54
|
|
|
55
|
-
## Error
|
|
55
|
+
## Error classes
|
|
56
56
|
|
|
57
57
|
Workflow SDK includes error classes that can be thrown in a workflow or step to change the error exit strategy of a workflow.
|
|
58
58
|
|
|
@@ -31,7 +31,7 @@ async function retryStep() {
|
|
|
31
31
|
The difference between `Error` and `RetryableError` may not be entirely obvious, since when both are thrown, they both retry. The difference is that `RetryableError` has an additional configurable `retryAfter` parameter.
|
|
32
32
|
</Callout>
|
|
33
33
|
|
|
34
|
-
## API
|
|
34
|
+
## API signature
|
|
35
35
|
|
|
36
36
|
### Parameters
|
|
37
37
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: setAttributes
|
|
3
|
+
description: Attach string metadata to workflow run for observability.
|
|
4
|
+
type: reference
|
|
5
|
+
summary: Use setAttributes inside a workflow or step function to set run attributes.
|
|
6
|
+
prerequisites:
|
|
7
|
+
- /docs/foundations/workflows-and-steps
|
|
8
|
+
related:
|
|
9
|
+
- /docs/observability/attributes
|
|
10
|
+
- /docs/api-reference/workflow/fatal-error
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
Attaches string metadata to the current workflow run.
|
|
14
|
+
|
|
15
|
+
```typescript lineNumbers
|
|
16
|
+
import { setAttributes } from "workflow"
|
|
17
|
+
|
|
18
|
+
export async function orderWorkflow(orderId: string) {
|
|
19
|
+
"use workflow"
|
|
20
|
+
|
|
21
|
+
await setAttributes({
|
|
22
|
+
phase: "received",
|
|
23
|
+
orderId,
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## API signature
|
|
29
|
+
|
|
30
|
+
### Parameters
|
|
31
|
+
|
|
32
|
+
<TSDoc
|
|
33
|
+
definition={`
|
|
34
|
+
import { setAttributes } from "workflow";
|
|
35
|
+
export default setAttributes;`}
|
|
36
|
+
showSections={['parameters']}
|
|
37
|
+
/>
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
Call `setAttributes` from a `"use workflow"` function or a `"use step"` function. Calling it from plain application code is not supported because there is no active workflow run.
|
|
42
|
+
|
|
43
|
+
Attribute values must be strings. Pass `undefined` to remove an attribute:
|
|
44
|
+
|
|
45
|
+
```typescript lineNumbers
|
|
46
|
+
import { setAttributes } from "workflow"
|
|
47
|
+
|
|
48
|
+
export async function cleanupAttributes() {
|
|
49
|
+
"use workflow"
|
|
50
|
+
|
|
51
|
+
await setAttributes({ staleKey: undefined })
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Attribute keys must be 1-256 characters, values must be strings up to 256 bytes, and each run can have up to 64 attributes. Keys that start with `$` are reserved for framework and library code.
|
|
56
|
+
|
|
57
|
+
Each call's complete `attr_set` event data must also fit in **8192 UTF-8 JSON bytes (8KiB)**. This includes the change keys and values, JSON escaping and structure, writer metadata (including the step ID and attempt for step calls), and the reserved-key option when enabled. It is not a limit on values alone. Split large updates into smaller calls; updates across multiple calls are not atomic and still share the 64-attribute per-run limit.
|
|
58
|
+
|
|
59
|
+
Validation errors reject `setAttributes` with [`FatalError`](/docs/api-reference/workflow/fatal-error) before a new attribute write is attempted. Catch the error if the metadata is best-effort; an uncaught error fails the workflow or step. Previously persisted attribute events remain replayable.
|
|
60
|
+
|
|
61
|
+
Calls from both workflow and step bodies append a native `attr_set` event, which the World materializes onto `run.attributes`. Workflow-originated events record a workflow writer; step-originated events record the originating step ID and attempt.
|
|
62
|
+
|
|
63
|
+
Native attributes require spec version 4 or later. Step-body storage errors throw from `setAttributes`; catch them inside the step if the write should be best-effort. Workflow-body writes are committed when the workflow suspends: transient storage errors are retried with the suspension, while a write the World rejects as invalid (such as exceeding the per-run attribute cap across multiple calls) fails the run with the validation error.
|
|
@@ -14,7 +14,7 @@ Suspends a workflow for a specified duration or until an end date without consum
|
|
|
14
14
|
This is useful when you want to resume a workflow after some duration or date.
|
|
15
15
|
|
|
16
16
|
<Callout>
|
|
17
|
-
`sleep` is a
|
|
17
|
+
`sleep` is a built-in workflow runtime function (backed by a timer event in the event log, not a step) and should be called directly inside workflow functions.
|
|
18
18
|
</Callout>
|
|
19
19
|
|
|
20
20
|
```typescript lineNumbers
|
|
@@ -26,7 +26,7 @@ async function testWorkflow() {
|
|
|
26
26
|
}
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
## API
|
|
29
|
+
## API signature
|
|
30
30
|
|
|
31
31
|
### Parameters
|
|
32
32
|
|
|
@@ -39,7 +39,7 @@ showSections={['parameters']}
|
|
|
39
39
|
|
|
40
40
|
## Examples
|
|
41
41
|
|
|
42
|
-
### Sleeping
|
|
42
|
+
### Sleeping with a duration
|
|
43
43
|
|
|
44
44
|
You can specify a duration for `sleep` to suspend the workflow for a fixed amount of time.
|
|
45
45
|
|
|
@@ -52,7 +52,7 @@ async function testWorkflow() {
|
|
|
52
52
|
}
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
### Sleeping
|
|
55
|
+
### Sleeping until an end date
|
|
56
56
|
|
|
57
57
|
You can specify a future `Date` object for `sleep` to suspend the workflow until a specific date.
|
|
58
58
|
|
|
@@ -6,7 +6,6 @@ summary: Cancel in-flight work with AbortSignal or stop entire workflow runs.
|
|
|
6
6
|
prerequisites:
|
|
7
7
|
- /docs/foundations/workflows-and-steps
|
|
8
8
|
related:
|
|
9
|
-
- /docs/foundations/common-patterns
|
|
10
9
|
- /docs/foundations/hooks
|
|
11
10
|
- /docs/how-it-works/cancellation
|
|
12
11
|
---
|
|
@@ -15,7 +14,7 @@ Workflow DevKit supports two cancellation mechanisms: **AbortSignal** for fine-g
|
|
|
15
14
|
|
|
16
15
|
## AbortSignal
|
|
17
16
|
|
|
18
|
-
`AbortController` and `AbortSignal` work across workflow and step boundaries. Create an `AbortController` with `new AbortController()` in a workflow function, pass its signal to steps, and call `abort()`
|
|
17
|
+
`AbortController` and `AbortSignal` work across workflow and step boundaries. Create an `AbortController` with `new AbortController()` in a workflow function, pass its signal to steps, and call `abort()` using the standard [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) API.
|
|
19
18
|
|
|
20
19
|
```typescript lineNumbers
|
|
21
20
|
import { sleep } from "workflow";
|
|
@@ -49,17 +48,17 @@ async function longRunningStep(signal: AbortSignal) {
|
|
|
49
48
|
}
|
|
50
49
|
```
|
|
51
50
|
|
|
52
|
-
|
|
51
|
+
Use the standard `AbortController` API without special imports or wrapper functions.
|
|
53
52
|
|
|
54
53
|
<Callout type="info">
|
|
55
|
-
Cancellation is **cooperative**. Aborting a signal doesn't forcefully kill a step
|
|
54
|
+
Cancellation is **cooperative**. Aborting a signal doesn't forcefully kill a step. The step's code must check `signal.aborted` or pass the signal to APIs like `fetch` that respect it. If a step ignores the signal, it runs to completion.
|
|
56
55
|
</Callout>
|
|
57
56
|
|
|
58
57
|
<Callout type="info">
|
|
59
58
|
To learn how `AbortController` works durably across workflow suspensions, replays, and step boundaries, see [How Cancellation Works](/docs/how-it-works/cancellation).
|
|
60
59
|
</Callout>
|
|
61
60
|
|
|
62
|
-
### Timeout with
|
|
61
|
+
### Timeout with cancellation
|
|
63
62
|
|
|
64
63
|
Race a step against a timeout, and cancel the step if the timeout wins:
|
|
65
64
|
|
|
@@ -91,7 +90,7 @@ async function fetchUrl(url: string, signal: AbortSignal) {
|
|
|
91
90
|
}
|
|
92
91
|
```
|
|
93
92
|
|
|
94
|
-
### Cancelling
|
|
93
|
+
### Cancelling parallel work
|
|
95
94
|
|
|
96
95
|
When racing multiple steps, cancel the losers:
|
|
97
96
|
|
|
@@ -117,7 +116,7 @@ async function fetchUrl(url: string, signal: AbortSignal) {
|
|
|
117
116
|
}
|
|
118
117
|
```
|
|
119
118
|
|
|
120
|
-
### Passing
|
|
119
|
+
### Passing signal through a pipeline
|
|
121
120
|
|
|
122
121
|
Pass the same signal to a chain of steps. Aborting cancels whichever step is currently running:
|
|
123
122
|
|
|
@@ -176,7 +175,7 @@ async function uploadData(data: ArrayBuffer, signal: AbortSignal) {
|
|
|
176
175
|
}
|
|
177
176
|
```
|
|
178
177
|
|
|
179
|
-
### Step-
|
|
178
|
+
### Step-initiated abort
|
|
180
179
|
|
|
181
180
|
A step can receive the full `AbortController` and call `abort()` to cancel parallel work. This is useful for watchdog/monitor patterns where one step observes an external condition and cancels other in-flight steps:
|
|
182
181
|
|
|
@@ -221,7 +220,7 @@ async function monitorQuota(userId: string, controller: AbortController) {
|
|
|
221
220
|
}
|
|
222
221
|
```
|
|
223
222
|
|
|
224
|
-
### User-
|
|
223
|
+
### User-triggered cancellation with hooks
|
|
225
224
|
|
|
226
225
|
Combine hooks with abort controllers to let users cancel in-flight work from an external API:
|
|
227
226
|
|
|
@@ -267,23 +266,23 @@ export async function POST(request: Request) {
|
|
|
267
266
|
}
|
|
268
267
|
```
|
|
269
268
|
|
|
270
|
-
### How
|
|
269
|
+
### How steps handle abort
|
|
271
270
|
|
|
272
271
|
When an `AbortSignal` is aborted, the behavior depends on how the step uses it:
|
|
273
272
|
|
|
274
|
-
| Usage | Behavior on
|
|
273
|
+
| Usage | Behavior on abort |
|
|
275
274
|
|-------|-------------------|
|
|
276
|
-
| `fetch(url, { signal })` | Request is
|
|
275
|
+
| `fetch(url, { signal })` | Request is canceled, throws `AbortError` |
|
|
277
276
|
| `signal.throwIfAborted()` | Throws the abort reason |
|
|
278
277
|
| `signal.aborted` check | Returns `true`, step can exit gracefully |
|
|
279
278
|
| `signal.addEventListener('abort', fn)` | Callback fires, step can clean up |
|
|
280
279
|
| Ignored | Step runs to completion (abort is cooperative) |
|
|
281
280
|
|
|
282
|
-
### Abort
|
|
281
|
+
### Abort errors skip retries
|
|
283
282
|
|
|
284
|
-
When a step throws due to an abort (
|
|
283
|
+
When a step throws due to an abort (for example, `fetch` throws `AbortError`, or `signal.throwIfAborted()` throws), the runtime wraps the error in a `FatalError`. The step **skips retries**, and the error immediately bubbles up to the workflow.
|
|
285
284
|
|
|
286
|
-
|
|
285
|
+
An abort is an intentional cancellation, so retrying the step would result in another abort. You don't need to manually wrap abort errors in `FatalError`.
|
|
287
286
|
|
|
288
287
|
```typescript lineNumbers
|
|
289
288
|
import { sleep } from "workflow";
|
|
@@ -300,7 +299,7 @@ export async function workflow() {
|
|
|
300
299
|
if (result === null) controller.abort();
|
|
301
300
|
return result;
|
|
302
301
|
} catch (err) {
|
|
303
|
-
// AbortError arrives as FatalError
|
|
302
|
+
// AbortError arrives as FatalError, with no retries attempted // [!code highlight]
|
|
304
303
|
return { status: "cancelled" };
|
|
305
304
|
}
|
|
306
305
|
}
|
|
@@ -313,7 +312,7 @@ async function cancellableStep(signal: AbortSignal) {
|
|
|
313
312
|
}
|
|
314
313
|
```
|
|
315
314
|
|
|
316
|
-
### Passing AbortSignal as
|
|
315
|
+
### Passing AbortSignal as workflow input
|
|
317
316
|
|
|
318
317
|
You can pass an `AbortSignal` from external code into a workflow via `start()`:
|
|
319
318
|
|
|
@@ -330,15 +329,15 @@ export async function POST(request: Request) {
|
|
|
330
329
|
}
|
|
331
330
|
```
|
|
332
331
|
|
|
333
|
-
When the signal is serialized at the `start()` boundary, an event listener
|
|
332
|
+
When the signal is serialized at the `start()` boundary, an event listener attaches to the external signal and writes the cancellation packet to the backing stream. The external `abort()` propagates into the workflow only while the originating process is still alive (the same constraint as passing a `ReadableStream` as input).
|
|
334
333
|
|
|
335
334
|
<Callout type="info">
|
|
336
335
|
For reliable external cancellation that works regardless of process lifetime, prefer the [User-Triggered Cancellation with Hooks](#user-triggered-cancellation-with-hooks) pattern. Hooks are durable and don't depend on the caller's process staying alive.
|
|
337
336
|
</Callout>
|
|
338
337
|
|
|
339
|
-
## Run
|
|
338
|
+
## Run cancellation
|
|
340
339
|
|
|
341
|
-
Run cancellation stops an entire workflow at the next suspension point. Unlike `AbortSignal`, it is not cooperative
|
|
340
|
+
Run cancellation stops an entire workflow at the next suspension point. Unlike `AbortSignal`, it is not cooperative. The workflow does not continue executing after cancellation.
|
|
342
341
|
|
|
343
342
|
```typescript title="app/api/cancel-run/route.ts" lineNumbers
|
|
344
343
|
import { getRun } from "workflow/api";
|
|
@@ -354,10 +353,10 @@ export async function POST(request: Request) {
|
|
|
354
353
|
```
|
|
355
354
|
|
|
356
355
|
<Callout type="info">
|
|
357
|
-
Calling `run.cancel()` is the same action as clicking the **Cancel** button on a run in the observability UI
|
|
356
|
+
Calling `run.cancel()` is the same action as clicking the **Cancel** button on a run in the observability UI. Both produce identical `run_cancelled` events in the event log.
|
|
358
357
|
</Callout>
|
|
359
358
|
|
|
360
|
-
When a run is
|
|
359
|
+
When a run is canceled:
|
|
361
360
|
- The workflow stops at its next suspension point (step call, hook await, or sleep)
|
|
362
361
|
- A `run_cancelled` event is recorded in the [event log](/docs/how-it-works/event-sourcing)
|
|
363
362
|
- All associated hooks are disposed and their tokens released
|
|
@@ -367,19 +366,19 @@ When a run is cancelled:
|
|
|
367
366
|
Run cancellation does **not** automatically abort any outstanding `AbortSignal`s. Steps that are currently executing will run to completion. If you need in-flight cancellation of specific operations, use `AbortSignal`.
|
|
368
367
|
</Callout>
|
|
369
368
|
|
|
370
|
-
## AbortSignal vs.
|
|
369
|
+
## AbortSignal vs. run cancellation
|
|
371
370
|
|
|
372
371
|
| | AbortSignal | Run Cancellation |
|
|
373
372
|
|---|---|---|
|
|
374
373
|
| **Scope** | Individual operations within a step | Entire workflow run |
|
|
375
374
|
| **Triggered by** | Your code (`controller.abort()`) | External API (`run.cancel()`) |
|
|
376
|
-
| **Cooperative** | Yes
|
|
375
|
+
| **Cooperative** | Yes. Steps must check the signal | No. The workflow stops at the next suspension point |
|
|
377
376
|
| **Granularity** | Can target specific steps or operations | All-or-nothing |
|
|
378
377
|
| **In-flight steps** | Aborted immediately if using the signal | Run to completion |
|
|
379
378
|
|
|
380
379
|
Use `AbortSignal` when you need fine-grained, in-flight cancellation of specific operations. Use run cancellation when you want to stop the entire workflow.
|
|
381
380
|
|
|
382
|
-
## Best
|
|
381
|
+
## Best practices
|
|
383
382
|
|
|
384
383
|
**Use `throwIfAborted()` before expensive work.** This throws the signal's abort reason if the signal is already aborted, preventing wasted compute:
|
|
385
384
|
|
|
@@ -449,12 +448,12 @@ export async function workflow() {
|
|
|
449
448
|
}
|
|
450
449
|
```
|
|
451
450
|
|
|
452
|
-
This is safe even if both steps have already completed
|
|
451
|
+
This is safe even if both steps have already completed because aborting a finished operation is a no-op.
|
|
453
452
|
|
|
454
|
-
## Related
|
|
453
|
+
## Related documentation
|
|
455
454
|
|
|
456
|
-
- [How Cancellation Works](/docs/how-it-works/cancellation)
|
|
457
|
-
- [Serialization](/docs/foundations/serialization)
|
|
458
|
-
- [
|
|
459
|
-
- [Hooks](/docs/foundations/hooks)
|
|
460
|
-
- [Errors and Retries](/docs/foundations/errors-and-retries)
|
|
455
|
+
- [How Cancellation Works](/docs/how-it-works/cancellation): Hook and stream backing, serialization internals
|
|
456
|
+
- [Serialization](/docs/foundations/serialization): Understanding serializable types
|
|
457
|
+
- [Cookbook](/cookbook): Timeout, race, and other reliability patterns
|
|
458
|
+
- [Hooks](/docs/foundations/hooks): Pausing workflows for external events
|
|
459
|
+
- [Errors and Retries](/docs/foundations/errors-and-retries): Handling step failures
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Errors & Retrying
|
|
3
|
-
description: Customize retry behavior with FatalError and RetryableError
|
|
3
|
+
description: Customize retry behavior with FatalError and RetryableError.
|
|
4
4
|
type: conceptual
|
|
5
5
|
summary: Control how steps handle failures and customize retry behavior.
|
|
6
6
|
prerequisites:
|
|
@@ -12,7 +12,7 @@ related:
|
|
|
12
12
|
|
|
13
13
|
By default, errors thrown inside steps are retried. Additionally, Workflow SDK provides two new types of errors you can use to customize retries.
|
|
14
14
|
|
|
15
|
-
## Default
|
|
15
|
+
## Default retrying
|
|
16
16
|
|
|
17
17
|
By default, steps retry up to 3 times on arbitrary errors. You can customize the number of retries by adding a `maxRetries` property to the step function.
|
|
18
18
|
|
|
@@ -42,9 +42,9 @@ Steps get enqueued immediately after a failure. Read on to see how this can be c
|
|
|
42
42
|
more information.
|
|
43
43
|
</Callout>
|
|
44
44
|
|
|
45
|
-
## Intentional
|
|
45
|
+
## Intentional errors
|
|
46
46
|
|
|
47
|
-
When your step needs to intentionally throw an error and skip retrying,
|
|
47
|
+
When your step needs to intentionally throw an error and skip retrying, throw a [`FatalError`](/docs/api-reference/workflow/fatal-error).
|
|
48
48
|
|
|
49
49
|
```typescript lineNumbers
|
|
50
50
|
import { FatalError } from "workflow";
|
|
@@ -67,7 +67,7 @@ async function callApi(endpoint: string) {
|
|
|
67
67
|
}
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
## Customize
|
|
70
|
+
## Customize retry behavior
|
|
71
71
|
|
|
72
72
|
When you need to customize the delay on a retry, use [`RetryableError`](/docs/api-reference/workflow/retryable-error) and set the `retryAfter` property.
|
|
73
73
|
|
|
@@ -97,7 +97,7 @@ async function callApi(endpoint: string) {
|
|
|
97
97
|
}
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
-
## Advanced
|
|
100
|
+
## Advanced example
|
|
101
101
|
|
|
102
102
|
This final example combines everything we've learned, along with [`getStepMetadata`](/docs/api-reference/workflow/get-step-metadata).
|
|
103
103
|
|
|
@@ -139,7 +139,42 @@ callApi.maxRetries = 5; // Retry up to 5 times on failure (6 total attempts)
|
|
|
139
139
|
step can run up to 4 times total (1 initial attempt + 3 retries).
|
|
140
140
|
</Callout>
|
|
141
141
|
|
|
142
|
-
##
|
|
142
|
+
## Serialization failures
|
|
143
|
+
|
|
144
|
+
A step whose arguments or return value cannot be [serialized](/docs/foundations/serialization) fails like a step whose body threw a `FatalError`: the failure is deterministic, so it skips the retry loop, and a `try/catch` around the step call observes the `SerializationError`:
|
|
145
|
+
|
|
146
|
+
```typescript lineNumbers
|
|
147
|
+
async function someStep(input: unknown) {
|
|
148
|
+
"use step";
|
|
149
|
+
return input;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export async function myWorkflow(input: unknown) {
|
|
153
|
+
"use workflow";
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
await someStep(input);
|
|
157
|
+
} catch (err) {
|
|
158
|
+
if ((err as Error).name === "SerializationError") {
|
|
159
|
+
// e.g. `Failed to serialize step arguments at path "..."`
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Uncaught, the run fails immediately with the `USER_ERROR` code, without retrying. See [serialization-failed](/docs/errors/serialization-failed) for common causes and fixes.
|
|
166
|
+
|
|
167
|
+
## Backend connection failures
|
|
168
|
+
|
|
169
|
+
On Vercel, backend connection failures and interrupted event streams use the existing retry policies, even when their error codes are unrecognized. This lets workflows recover from network failures instead of immediately failing with `USER_ERROR`. Persistent failures can still exhaust the retry budget.
|
|
170
|
+
|
|
171
|
+
The SDK also replaces its shared events connection pool after repeated HTTP/2 session failures. Invalid backend URLs, including unsupported protocols and embedded credentials, fail immediately. Fetch requests to blocked ports or with unsupported headers (such as `Expect`) also fail without retrying. Interrupted event writes retain their existing retries; caller cancellations do not trigger another write.
|
|
172
|
+
|
|
173
|
+
A connection failure does not prove that the backend rejected a write: it may have accepted it before the response was lost. Continue to make step side effects [idempotent](/docs/foundations/idempotency).
|
|
174
|
+
|
|
175
|
+
Failed-run logs include the underlying error causes and their codes, exposing socket, DNS, or TLS errors behind messages such as `TypeError: fetch failed`. If a cause cannot be read, the log includes `[unavailable cause]` and the run can still be recorded as failed.
|
|
176
|
+
|
|
177
|
+
## Error codes
|
|
143
178
|
|
|
144
179
|
When a workflow run fails, the error includes an `errorCode` that classifies the failure, alongside the original thrown value (preserved as `cause`):
|
|
145
180
|
|
|
@@ -153,7 +188,7 @@ try {
|
|
|
153
188
|
const result = await run.returnValue;
|
|
154
189
|
} catch (err) {
|
|
155
190
|
if (WorkflowRunFailedError.is(err)) {
|
|
156
|
-
console.log(err.errorCode); // "USER_ERROR", "
|
|
191
|
+
console.log(err.errorCode); // e.g. "USER_ERROR", "MAX_EVENTS_EXCEEDED", or undefined
|
|
157
192
|
// `cause` is the original thrown value, hydrated through the workflow
|
|
158
193
|
// serialization pipeline. It can be any thrown value, so check shape.
|
|
159
194
|
if (err.cause instanceof Error) {
|
|
@@ -166,13 +201,21 @@ try {
|
|
|
166
201
|
| Code | Meaning |
|
|
167
202
|
| --- | --- |
|
|
168
203
|
| `USER_ERROR` | An error thrown in your workflow or step code (including propagated step failures like `FatalError`) |
|
|
169
|
-
| `
|
|
204
|
+
| `MAX_EVENTS_EXCEEDED` | The run reached the World's per-run event ceiling (for the Vercel World, see [Workflow run limits](https://vercel.com/docs/workflows/pricing#workflow-run-limits)). Split unbounded loops into [child workflows](/cookbook/advanced/child-workflows) well before the ceiling; see [Vercel World limits](/worlds/vercel#per-run-limits) and [Limits](/docs/configuration/runtime-tuning#limits) |
|
|
205
|
+
| `MAX_DELIVERIES_EXCEEDED` | The run exceeded the maximum number of queue deliveries |
|
|
206
|
+
| `REPLAY_TIMEOUT` | A workflow replay exceeded the maximum allowed duration |
|
|
207
|
+
| `REPLAY_DIVERGENCE` | A replay could not consume the event log deterministically, usually because of non-deterministic workflow code. |
|
|
208
|
+
| `CORRUPTED_EVENT_LOG` | The event log cannot be replayed: it contains orphaned or mismatched events, or one of its stored payloads is no longer readable from the World's storage. If you see this, please [file an issue](https://github.com/vercel/workflow/issues) |
|
|
209
|
+
| `STREAM_ERROR` | Workflow stream infrastructure failed while reading or writing data. This is an SDK or backend failure rather than an error in workflow code |
|
|
210
|
+
| `WORLD_CONTRACT_ERROR` | A World response violated the SDK contract; points at a World implementation bug |
|
|
211
|
+
| `DEPLOYMENT_MISMATCH` | The run was delivered to a deployment other than the one it is pinned to, and automatic re-routing did not recover it |
|
|
212
|
+
| `RUNTIME_ERROR` | An internal runtime error. If you see this, please [file an issue](https://github.com/vercel/workflow/issues) |
|
|
170
213
|
|
|
171
214
|
<Callout type="info">
|
|
172
|
-
The error code is also available on the run entity
|
|
215
|
+
The error code is also available on the run entity through the Workflow CLI (`npx workflow inspect runs <runId>`) in the `error.code` field, and as an OpenTelemetry span attribute (`workflow.error.code`) for observability.
|
|
173
216
|
</Callout>
|
|
174
217
|
|
|
175
|
-
## Rolling
|
|
218
|
+
## Rolling back failed steps
|
|
176
219
|
|
|
177
220
|
When a workflow fails partway through, it can leave the system in an inconsistent state.
|
|
178
221
|
A common pattern to address this is "rollbacks": for each successful step, record a corresponding rollback action that can undo it.
|