workflow 5.0.0-beta.42 → 5.0.0-beta.44
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 +32 -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 +14 -14
- 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 +79 -0
- package/docs/changelog/eager-processing.mdx +63 -63
- package/docs/changelog/index.mdx +3 -3
- package/docs/changelog/lazy-event-creation.md +27 -27
- package/docs/changelog/meta.json +2 -1
- package/docs/changelog/resilient-resume.mdx +5 -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 +102 -21
- package/docs/configuration/worlds.mdx +34 -12
- 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 +13 -14
- 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 +3 -3
- 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 +37 -37
- 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 +68 -39
- 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 +84 -28
- 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 +35 -35
- package/docs/testing/server-based.mdx +10 -10
- package/docs/whats-new.mdx +185 -0
- package/package.json +12 -12
|
@@ -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"
|
|
@@ -9,7 +9,7 @@ related:
|
|
|
9
9
|
|
|
10
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
11
|
|
|
12
|
-
[`run.returnValue()`](/docs/api-reference/workflow-api/get-run) handles this error internally
|
|
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
13
|
|
|
14
14
|
```typescript lineNumbers
|
|
15
15
|
import { WorkflowRunNotCompletedError } 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 WorkflowRunNotCompletedError {
|
|
|
42
42
|
export default WorkflowRunNotCompletedError;`}
|
|
43
43
|
/>
|
|
44
44
|
|
|
45
|
-
### Static
|
|
45
|
+
### Static methods
|
|
46
46
|
|
|
47
47
|
#### `WorkflowRunNotCompletedError.is(value)`
|
|
48
48
|
|
|
49
|
-
Type-safe check for `WorkflowRunNotCompletedError` instances. Preferred over `instanceof` because it works across module boundaries and
|
|
49
|
+
Type-safe check for `WorkflowRunNotCompletedError` instances. Preferred over `instanceof` because it works across module boundaries and virtual machine contexts.
|
|
50
50
|
|
|
51
51
|
```typescript
|
|
52
52
|
import { WorkflowRunNotCompletedError } from "workflow/errors"
|
|
@@ -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"
|
|
@@ -27,7 +27,7 @@ try {
|
|
|
27
27
|
}
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
## API
|
|
30
|
+
## API signature
|
|
31
31
|
|
|
32
32
|
### Properties
|
|
33
33
|
|
|
@@ -42,7 +42,7 @@ interface WorkflowRuntimeError {
|
|
|
42
42
|
export default WorkflowRuntimeError;`}
|
|
43
43
|
/>
|
|
44
44
|
|
|
45
|
-
### Static
|
|
45
|
+
### Static methods
|
|
46
46
|
|
|
47
47
|
#### `WorkflowRuntimeError.is(value)`
|
|
48
48
|
|
|
@@ -12,7 +12,7 @@ related:
|
|
|
12
12
|
|
|
13
13
|
`WorkflowWorldError` is the base error class for failures originating from a workflow world (storage backend). World implementations (local, Postgres, Vercel) throw subclasses of this error when storage operations fail.
|
|
14
14
|
|
|
15
|
-
You can use `instanceof WorkflowWorldError` to catch any
|
|
15
|
+
You can use `instanceof WorkflowWorldError` to catch any World-related error regardless of the specific type. The static `.is()` method only matches errors constructed directly as `WorkflowWorldError`. Use the subclass-specific `.is()` methods (for example, `EntityConflictError.is()`) to match specific error types.
|
|
16
16
|
|
|
17
17
|
<Callout>
|
|
18
18
|
Most world errors are handled automatically by the Workflow runtime. You will typically only encounter these errors when interacting with world storage APIs directly or when there are infrastructure-level issues.
|
|
@@ -33,7 +33,7 @@ try {
|
|
|
33
33
|
}
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
## API
|
|
36
|
+
## API signature
|
|
37
37
|
|
|
38
38
|
### Properties
|
|
39
39
|
|
|
@@ -54,11 +54,11 @@ interface WorkflowWorldError {
|
|
|
54
54
|
export default WorkflowWorldError;`}
|
|
55
55
|
/>
|
|
56
56
|
|
|
57
|
-
### Static
|
|
57
|
+
### Static methods
|
|
58
58
|
|
|
59
59
|
#### `WorkflowWorldError.is(value)`
|
|
60
60
|
|
|
61
|
-
Type-safe check that matches only errors constructed directly as `WorkflowWorldError`. Does not match subclasses like `EntityConflictError
|
|
61
|
+
Type-safe check that matches only errors constructed directly as `WorkflowWorldError`. Does not match subclasses like `EntityConflictError`. Use `instanceof` to catch all world errors, or the subclass-specific `.is()` methods.
|
|
62
62
|
|
|
63
63
|
```typescript
|
|
64
64
|
import { WorkflowWorldError } from "workflow/errors"
|
|
@@ -73,7 +73,7 @@ if (WorkflowWorldError.is(error)) {
|
|
|
73
73
|
|
|
74
74
|
The following error types extend `WorkflowWorldError`:
|
|
75
75
|
|
|
76
|
-
- [`EntityConflictError`](/docs/api-reference/workflow-errors/entity-conflict-error)
|
|
77
|
-
- [`RunExpiredError`](/docs/api-reference/workflow-errors/run-expired-error)
|
|
78
|
-
- [`TooEarlyError`](/docs/api-reference/workflow-errors/too-early-error)
|
|
79
|
-
- [`ThrottleError`](/docs/api-reference/workflow-errors/throttle-error)
|
|
76
|
+
- [`EntityConflictError`](/docs/api-reference/workflow-errors/entity-conflict-error): operation conflicts with entity state
|
|
77
|
+
- [`RunExpiredError`](/docs/api-reference/workflow-errors/run-expired-error): run has expired
|
|
78
|
+
- [`TooEarlyError`](/docs/api-reference/workflow-errors/too-early-error): request made before system is ready
|
|
79
|
+
- [`ThrottleError`](/docs/api-reference/workflow-errors/throttle-error): request was rate-limited
|
|
@@ -22,29 +22,30 @@ These APIs are available but are **seeded or fixed** to ensure deterministic beh
|
|
|
22
22
|
|
|
23
23
|
| API | Behavior |
|
|
24
24
|
|-----|----------|
|
|
25
|
-
| [`Math.random()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) | Seeded random number generator
|
|
25
|
+
| [`Math.random()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) | Seeded random number generator: same seed produces the same sequence every replay |
|
|
26
26
|
| [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) / `Date.now()` / `new Date()` | Returns a fixed timestamp that advances with the workflow's logical clock |
|
|
27
|
-
| [`crypto.getRandomValues()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) | Seeded
|
|
28
|
-
| [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID) | Seeded
|
|
27
|
+
| [`crypto.getRandomValues()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) | Seeded: produces deterministic output for a given workflow run |
|
|
28
|
+
| [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID) | Seeded: produces deterministic UUIDs for a given workflow run |
|
|
29
29
|
| [`crypto.subtle.digest()`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest) | Computed synchronously via `node:crypto` (values are byte-identical to WebCrypto), so the promise settles at a deterministic point during replay |
|
|
30
30
|
|
|
31
31
|
<Callout type="info">
|
|
32
32
|
You can safely use `Math.random()`, `Date.now()`, and `crypto.randomUUID()` in workflow functions. The framework ensures these return the same values across replays.
|
|
33
33
|
</Callout>
|
|
34
34
|
|
|
35
|
-
## Web
|
|
35
|
+
## Web platform APIs
|
|
36
36
|
|
|
37
37
|
These standard Web APIs are available in workflow functions:
|
|
38
38
|
|
|
39
39
|
- [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers)
|
|
40
40
|
- [`TextEncoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder) / [`TextDecoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder)
|
|
41
41
|
- [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) / [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
|
|
42
|
-
- [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) / [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
42
|
+
- [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) / [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response): custom implementations with [special behavior in the workflow context](/docs/foundations/serialization#request--response). Body methods like `.json()` and `.text()` are automatically treated as step invocations.
|
|
43
43
|
- [`console`](https://developer.mozilla.org/en-US/docs/Web/API/console)
|
|
44
44
|
- [`structuredClone`](https://developer.mozilla.org/en-US/docs/Web/API/Window/structuredClone)
|
|
45
45
|
- [`atob`](https://developer.mozilla.org/en-US/docs/Web/API/Window/atob) / [`btoa`](https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa)
|
|
46
|
+
- [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) / [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal): A durable, serializable implementation whose abort state survives replay and can be passed into steps to cancel in-flight work. See [Cancellation](/docs/foundations/cancellation).
|
|
46
47
|
|
|
47
|
-
## Environment
|
|
48
|
+
## Environment variables
|
|
48
49
|
|
|
49
50
|
`process.env` is available as a **read-only, frozen** snapshot of the environment variables at the time the workflow was started. You cannot modify it.
|
|
50
51
|
|
|
@@ -53,11 +54,11 @@ export async function myWorkflow() {
|
|
|
53
54
|
"use workflow";
|
|
54
55
|
|
|
55
56
|
const apiKey = process.env.API_KEY; // works
|
|
56
|
-
process.env.FOO = "bar"; // throws
|
|
57
|
+
process.env.FOO = "bar"; // throws: process.env is frozen
|
|
57
58
|
}
|
|
58
59
|
```
|
|
59
60
|
|
|
60
|
-
## Binary
|
|
61
|
+
## Binary data
|
|
61
62
|
|
|
62
63
|
Standard JavaScript typed arrays (`Uint8Array`, `Int32Array`, `Float64Array`, etc.) are available in workflow functions.
|
|
63
64
|
|
|
@@ -92,7 +93,7 @@ target.setFromHex("48656c6c6f"); // { read: 10, written: 5 }
|
|
|
92
93
|
These methods are polyfilled in the workflow environment. When the JavaScript runtime ships native support, the polyfill is automatically bypassed.
|
|
93
94
|
</Callout>
|
|
94
95
|
|
|
95
|
-
## Not
|
|
96
|
+
## Not available
|
|
96
97
|
|
|
97
98
|
The following are **not available** in workflow functions. Move this logic to [step functions](/docs/foundations/workflows-and-steps#step-functions) instead.
|
|
98
99
|
|
|
@@ -100,6 +101,6 @@ The following are **not available** in workflow functions. Move this logic to [s
|
|
|
100
101
|
- **Global `fetch`**: Use [`import { fetch } from "workflow"`](/docs/api-reference/workflow/fetch) instead. See [fetch-in-workflow](/docs/errors/fetch-in-workflow).
|
|
101
102
|
- **Timers**: `setTimeout`, `setInterval`, `setImmediate`, and their `clear*` counterparts. Use [`sleep()`](/docs/api-reference/workflow/sleep) instead. See [timeout-in-workflow](/docs/errors/timeout-in-workflow).
|
|
102
103
|
- **`Buffer`**: Node.js-specific API. Use `Uint8Array` with `toBase64()` / `fromBase64()` / `toHex()` / `fromHex()` for binary data encoding, or `atob()` / `btoa()` for string-based base64.
|
|
103
|
-
- **`WeakRef` and `FinalizationRegistry`**:
|
|
104
|
+
- **`WeakRef` and `FinalizationRegistry`**: Garbage collection timing is not deterministic, so observing it would make workflow code impossible to replay. (`WeakMap` and `WeakSet` remain available since they do not expose garbage collection state.)
|
|
104
105
|
- **`Atomics.waitAsync`**: a wall-clock timer, which cannot be replayed. Use [`sleep()`](/docs/api-reference/workflow/sleep) instead.
|
|
105
|
-
- **Async `WebAssembly` compilation
|
|
106
|
+
- **Async `WebAssembly` compilation**: The `compile`, `instantiate`, `compileStreaming`, and `instantiateStreaming` methods resolve on compile-thread timing. The synchronous `new WebAssembly.Module()` and `new WebAssembly.Instance()` constructors remain available.
|
|
@@ -9,7 +9,7 @@ prerequisites:
|
|
|
9
9
|
|
|
10
10
|
Configures the output directory that [`WorkflowController`](/docs/api-reference/workflow-nest/workflow-controller) loads the generated workflow bundles (`steps.mjs`, `workflows.mjs`, `webhook.mjs`, `manifest.json`) from.
|
|
11
11
|
|
|
12
|
-
[`WorkflowModule.forRoot()`](/docs/api-reference/workflow-nest/workflow-module) calls this for you with its resolved `outDir
|
|
12
|
+
[`WorkflowModule.forRoot()`](/docs/api-reference/workflow-nest/workflow-module) calls this for you with its resolved `outDir`. Call it yourself only when registering `WorkflowController` manually. The controller's route handlers throw if no directory has been configured.
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
@@ -20,7 +20,7 @@ import { configureWorkflowController } from "workflow/nest"; // [!code highlight
|
|
|
20
20
|
configureWorkflowController(join(process.cwd(), ".nestjs/workflow")); // [!code highlight]
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
## API
|
|
23
|
+
## API signature
|
|
24
24
|
|
|
25
25
|
### Parameters
|
|
26
26
|
|
|
@@ -7,7 +7,7 @@ prerequisites:
|
|
|
7
7
|
- /docs/getting-started/nestjs
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
Builder that scans a NestJS project for workflow files and compiles them into the step, workflow, and webhook bundles plus a manifest. [`WorkflowModule.forRoot()`](/docs/api-reference/workflow-nest/workflow-module) creates and runs one automatically on startup
|
|
10
|
+
Builder that scans a NestJS project for workflow files and compiles them into the step, workflow, and webhook bundles plus a manifest. [`WorkflowModule.forRoot()`](/docs/api-reference/workflow-nest/workflow-module) creates and runs one automatically on startup. Instantiate it yourself only when you need to build bundles outside the module lifecycle (e.g. a custom build script for production with `skipBuild`).
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
@@ -23,7 +23,7 @@ await builder.build(); // [!code highlight]
|
|
|
23
23
|
console.log(`Workflow bundles written to ${builder.outDir}`);
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
## API
|
|
26
|
+
## API signature
|
|
27
27
|
|
|
28
28
|
### Constructor
|
|
29
29
|
|
|
@@ -43,7 +43,7 @@ console.log(`Workflow bundles written to ${builder.outDir}`);
|
|
|
43
43
|
| `dirs` | `string[]` | `['src']` | Directories to scan for workflow files. |
|
|
44
44
|
| `outDir` | `string` | `'.nestjs/workflow'` (relative to `workingDir`) | Output directory for generated workflow bundles. |
|
|
45
45
|
| `watch` | `boolean` | `false` | Enable watch mode for development. |
|
|
46
|
-
| `moduleType` | `'es6' \| 'commonjs'` | `'es6'` | SWC module compilation type. When `'commonjs'`, the builder rewrites externalized imports in the steps bundle to use `require()`
|
|
46
|
+
| `moduleType` | `'es6' \| 'commonjs'` | `'es6'` | SWC module compilation type. When `'commonjs'`, the builder rewrites externalized imports in the steps bundle to use `require()` through `createRequire`, avoiding ECMAScript module (ESM) and CommonJS (CJS) named-export interop issues with SWC's output. |
|
|
47
47
|
| `distDir` | `string` | `'dist'` | Directory where NestJS compiles `.ts` source files to `.js` (relative to `workingDir`). Used when `moduleType` is `'commonjs'` to resolve compiled file paths. Should match the `outDir` in your `tsconfig.json`. |
|
|
48
48
|
| `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. Can also be set via the `WORKFLOW_SOURCEMAP` environment variable. |
|
|
49
49
|
|
|
@@ -57,7 +57,7 @@ Builds the workflow bundles. Writes `steps.mjs`, `workflows.mjs`, `webhook.mjs`,
|
|
|
57
57
|
|
|
58
58
|
#### `outDir`
|
|
59
59
|
|
|
60
|
-
Read-only getter that returns the output directory for generated workflow bundles
|
|
60
|
+
Read-only getter that returns the output directory for generated workflow bundles: the `outDir` option as passed, or the default `.nestjs/workflow` resolved against `workingDir`.
|
|
61
61
|
|
|
62
62
|
### Returns
|
|
63
63
|
|
|
@@ -9,7 +9,7 @@ prerequisites:
|
|
|
9
9
|
|
|
10
10
|
NestJS controller that handles the well-known workflow endpoints under `.well-known/workflow/v1`. It dynamically imports the generated workflow bundles and converts between Express/Fastify requests and the Web API `Request`/`Response` objects the workflow runtime expects. Both the Express and Fastify HTTP adapters are supported.
|
|
11
11
|
|
|
12
|
-
[`WorkflowModule.forRoot()`](/docs/api-reference/workflow-nest/workflow-module) registers this controller automatically
|
|
12
|
+
[`WorkflowModule.forRoot()`](/docs/api-reference/workflow-nest/workflow-module) registers this controller automatically. You only register it yourself if you are not using `WorkflowModule`.
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
@@ -40,9 +40,9 @@ import { WorkflowModule } from "workflow/nest";
|
|
|
40
40
|
export class AppModule {}
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
## API
|
|
43
|
+
## API signature
|
|
44
44
|
|
|
45
|
-
### Static
|
|
45
|
+
### Static methods
|
|
46
46
|
|
|
47
47
|
#### `forRoot(options?)`
|
|
48
48
|
|
|
@@ -56,7 +56,7 @@ Configures the module and returns a NestJS `DynamicModule` registered as `global
|
|
|
56
56
|
|
|
57
57
|
#### WorkflowModuleOptions
|
|
58
58
|
|
|
59
|
-
Extends [`NestBuilderOptions`](/docs/api-reference/workflow-nest/nest-local-builder#nestbuilderoptions)
|
|
59
|
+
Extends [`NestBuilderOptions`](/docs/api-reference/workflow-nest/nest-local-builder#nestbuilderoptions): all builder options are accepted, plus `skipBuild`:
|
|
60
60
|
|
|
61
61
|
| Option | Type | Default | Description |
|
|
62
62
|
| --- | --- | --- | --- |
|
|
@@ -65,7 +65,7 @@ Extends [`NestBuilderOptions`](/docs/api-reference/workflow-nest/nest-local-buil
|
|
|
65
65
|
| `dirs` | `string[]` | `['src']` | Directories to scan for workflow files. |
|
|
66
66
|
| `outDir` | `string` | `'.nestjs/workflow'` (relative to `workingDir`) | Output directory for generated workflow bundles. |
|
|
67
67
|
| `watch` | `boolean` | `false` | Enable watch mode for development. |
|
|
68
|
-
| `moduleType` | `'es6' \| 'commonjs'` | `'es6'` | SWC module compilation type. Set to `'commonjs'` if your NestJS project compiles to CJS
|
|
68
|
+
| `moduleType` | `'es6' \| 'commonjs'` | `'es6'` | SWC module compilation type. Set to `'commonjs'` if your NestJS project compiles to CommonJS (CJS) through SWC. |
|
|
69
69
|
| `distDir` | `string` | `'dist'` | Directory where NestJS compiles `.ts` source files to `.js` (relative to `workingDir`). Used when `moduleType` is `'commonjs'`. Should match the `outDir` in your `tsconfig.json`. |
|
|
70
70
|
| `sourcemap` | `boolean \| 'inline' \| 'linked' \| 'external' \| 'both'` | `'inline'` (dev) / `false` (prod) | Controls source maps on generated workflow bundles. Defaults to `'inline'` in development and `false` in production. Can also be set via the `WORKFLOW_SOURCEMAP` environment variable. |
|
|
71
71
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: withWorkflow
|
|
3
|
-
description: Configure webpack
|
|
3
|
+
description: Configure webpack and Turbopack to transform workflow directives in Next.js.
|
|
4
4
|
type: reference
|
|
5
5
|
summary: Wrap your Next.js config with withWorkflow to enable workflow directive transformation.
|
|
6
6
|
prerequisites:
|
|
7
7
|
- /docs/getting-started/next
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
Configures webpack
|
|
10
|
+
Configures webpack and Turbopack loaders to transform workflow code (`"use step"` and `"use workflow"` directives).
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
@@ -16,13 +16,13 @@ To enable `"use step"` and `"use workflow"` directives while developing locally
|
|
|
16
16
|
```typescript title="next.config.ts" lineNumbers
|
|
17
17
|
import { withWorkflow } from "workflow/next"; // [!code highlight]
|
|
18
18
|
import type { NextConfig } from "next";
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
const nextConfig: NextConfig = {
|
|
21
21
|
// … rest of your Next.js config
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
// not required but allows configuring workflow options
|
|
25
|
-
const workflowConfig = {}
|
|
25
|
+
const workflowConfig = {};
|
|
26
26
|
|
|
27
27
|
export default withWorkflow(nextConfig, workflowConfig); // [!code highlight]
|
|
28
28
|
```
|
|
@@ -36,22 +36,22 @@ Remove that package from `serverExternalPackages` in your
|
|
|
36
36
|
`next.config` to silence the warning.
|
|
37
37
|
</Callout>
|
|
38
38
|
|
|
39
|
-
### Workflow
|
|
39
|
+
### Workflow discovery in Next.js
|
|
40
40
|
|
|
41
|
-
`withWorkflow()` discovers workflows by scanning your Next.js entrypoints
|
|
42
|
-
Router `route`, `page`, and `layout` files
|
|
43
|
-
file under `pages/` or `src/pages/`
|
|
41
|
+
`withWorkflow()` discovers workflows by scanning your Next.js entrypoints (App
|
|
42
|
+
Router `route`, `page`, and `layout` files under `app/` or `src/app/`, and any
|
|
43
|
+
file under `pages/` or `src/pages/`) for `start()` calls imported from
|
|
44
44
|
`workflow/api`. The workflow and step files themselves can live anywhere (for
|
|
45
45
|
example `src/workflows/`); they are discovered transitively through imports, as
|
|
46
46
|
long as a `start()` call in an entrypoint statically reaches them.
|
|
47
47
|
|
|
48
48
|
<Callout type="info">
|
|
49
49
|
Call `start()` from server-side entrypoints, including Route Handlers and Server
|
|
50
|
-
Actions. Don't call workflow functions directly
|
|
50
|
+
Actions. Don't call workflow functions directly, which bypasses the workflow
|
|
51
51
|
runtime.
|
|
52
52
|
</Callout>
|
|
53
53
|
|
|
54
|
-
### Next.js
|
|
54
|
+
### Next.js server actions and `"use server"`
|
|
55
55
|
|
|
56
56
|
Don't put a top-level `"use server"` directive in modules imported by workflow
|
|
57
57
|
or step functions. Workflow transformation wraps imported modules in synchronous
|
|
@@ -60,7 +60,7 @@ with errors like `Server Actions must be async functions`. Keep `"use server"`
|
|
|
60
60
|
on the files that define your Server Actions, and move shared logic into
|
|
61
61
|
separate modules that don't carry the directive.
|
|
62
62
|
|
|
63
|
-
### Monorepos and
|
|
63
|
+
### Monorepos and workspace imports
|
|
64
64
|
|
|
65
65
|
By default, Next.js detects the correct workspace root automatically. If your Next.js app lives in a subdirectory such as `apps/web` and workspace resolution is not working correctly, you can set `outputFileTracingRoot` as a workaround:
|
|
66
66
|
|
|
@@ -107,7 +107,7 @@ export default withWorkflow(nextConfig, {
|
|
|
107
107
|
|
|
108
108
|
### Source maps
|
|
109
109
|
|
|
110
|
-
The step bundle and intermediate workflow bundle default to `'inline'` source maps **in development**
|
|
110
|
+
The step bundle and intermediate workflow bundle default to `'inline'` source maps **in development** (so stack traces from step errors and workflow virtual machine (VM) errors point at your source files) and to **`false` in production**, so function bundles stay small. The `sourcemap` option lets you change that:
|
|
111
111
|
|
|
112
112
|
| Value | Behavior |
|
|
113
113
|
| --- | --- |
|
|
@@ -117,10 +117,10 @@ The step bundle and intermediate workflow bundle default to `'inline'` source ma
|
|
|
117
117
|
| `'both'` | Emit both inline and external source maps. |
|
|
118
118
|
| `false` | Omit source maps entirely. |
|
|
119
119
|
|
|
120
|
-
In production, source maps are already off by default. Setting `sourcemap: false` explicitly also turns them off in development, and it drops the inline source map from every bundle while skipping the source-map-support runtime shim on the Vercel step function (the same behavior production gets by default)
|
|
120
|
+
In production, source maps are already off by default. Setting `sourcemap: false` explicitly also turns them off in development, and it drops the inline source map from every bundle while skipping the source-map-support runtime shim on the Vercel step function (the same behavior production gets by default), the main lever for staying under the Vercel 250 MB function size limit. The tradeoff is that workflow VM stack traces will reference generated code (for example, `evalmachine.<anonymous>`) rather than your source files.
|
|
121
121
|
|
|
122
122
|
<Callout type="info">
|
|
123
|
-
Setting `sourcemap` explicitly affects **all** generated bundles (steps, workflows, webhook). The legacy `WORKFLOW_EMIT_SOURCEMAPS_FOR_DEBUGGING=1` environment variable is narrower
|
|
123
|
+
Setting `sourcemap` explicitly affects **all** generated bundles (steps, workflows, webhook). The legacy `WORKFLOW_EMIT_SOURCEMAPS_FOR_DEBUGGING=1` environment variable is narrower: it only toggles source maps on the final workflow wrapper and webhook bundle (which default to off). It continues to work, but new code should use the `sourcemap` option or the `WORKFLOW_SOURCEMAP` environment variable instead.
|
|
124
124
|
</Callout>
|
|
125
125
|
|
|
126
126
|
The option can also be set via the `WORKFLOW_SOURCEMAP` environment variable, which accepts the same values plus `'0'` / `'1'` as aliases for `false` / `true`. Precedence is: explicit config > `WORKFLOW_SOURCEMAP` > the environment-aware default (`'inline'` in development, `false` in production). Development is detected from `next dev` / `NODE_ENV=development`, so the config option and the env var both let you force either behavior in either environment.
|
|
@@ -129,7 +129,7 @@ The option can also be set via the `WORKFLOW_SOURCEMAP` environment variable, wh
|
|
|
129
129
|
The `workflows.local` options only affect local development. When deployed to Vercel, the runtime ignores `local` settings and uses the Vercel world automatically.
|
|
130
130
|
</Callout>
|
|
131
131
|
|
|
132
|
-
## Exporting a
|
|
132
|
+
## Exporting a function
|
|
133
133
|
|
|
134
134
|
|
|
135
135
|
If you are exporting a function in your `next.config` you will need to ensure you call the function returned from `withWorkflow`.
|
|
@@ -158,4 +158,4 @@ export default async function config(
|
|
|
158
158
|
}
|
|
159
159
|
return nextConfig;
|
|
160
160
|
}
|
|
161
|
-
```
|
|
161
|
+
```
|
|
@@ -7,7 +7,7 @@ related:
|
|
|
7
7
|
- /docs/getting-started/nitro
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
Nitro integration for Workflow SDK. The `workflow/nitro` entry point's default export is a [Nitro module](https://v3.nitro.build/guide/modules)
|
|
10
|
+
Nitro integration for Workflow SDK. The `workflow/nitro` entry point's default export is a [Nitro module](https://v3.nitro.build/guide/modules): it has no callable API. You enable it by adding it to the `modules` array of your Nitro config and configure it via the `workflow` key.
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
@@ -26,10 +26,10 @@ When enabled, the module:
|
|
|
26
26
|
- Builds the workflow, step, and webhook bundles, and rebuilds them on file changes in development.
|
|
27
27
|
- Registers the workflow runtime routes under `/.well-known/workflow/v1/`.
|
|
28
28
|
- Serves a redirect to the local observability dashboard at `/_workflow` in development.
|
|
29
|
-
- Configures
|
|
29
|
+
- Configures function rules for Vercel Functions (queue triggers and `maxDuration`) on the workflow routes when deploying to Vercel.
|
|
30
30
|
- Uses Nitro's `workspaceDir` as the workflow project root so monorepo apps can import sibling workspace packages without extra workflow config.
|
|
31
31
|
|
|
32
|
-
## Module
|
|
32
|
+
## Module options
|
|
33
33
|
|
|
34
34
|
Options are read from the `workflow` key of your Nitro config. The option type is exported as `ModuleOptions`:
|
|
35
35
|
|
|
@@ -51,9 +51,9 @@ export default defineConfig({
|
|
|
51
51
|
| Option | Type | Default | Description |
|
|
52
52
|
| --- | --- | --- | --- |
|
|
53
53
|
| `dirs` | `string[]` | — | Directories to scan for workflows and steps. By default, the `workflows/` directory is scanned from the project root and all layer source directories. |
|
|
54
|
-
| `typescriptPlugin` | `boolean` | `false` | Adds the `workflow` TypeScript plugin to the generated `tsconfig.json` for IDE IntelliSense. |
|
|
55
|
-
| `runtime` | `string` | — | Node.js runtime version for Vercel Functions (
|
|
56
|
-
| `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
|
|
54
|
+
| `typescriptPlugin` | `boolean` | `false` | Adds the `workflow` TypeScript plugin to the generated `tsconfig.json` for integrated development environment (IDE) IntelliSense. |
|
|
55
|
+
| `runtime` | `string` | — | Node.js runtime version for Vercel Functions (for example, `'nodejs22.x'` or `'nodejs24.x'`). Only applies when deploying to Vercel. |
|
|
56
|
+
| `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. |
|
|
57
57
|
|
|
58
58
|
## Vite-based Nitro
|
|
59
59
|
|
|
@@ -7,7 +7,7 @@ related:
|
|
|
7
7
|
- /docs/getting-started/nuxt
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
Nuxt integration for Workflow SDK. The `workflow/nuxt` entry point's default export is a Nuxt module
|
|
10
|
+
Nuxt integration for Workflow SDK. The `workflow/nuxt` entry point's default export is a Nuxt module: it has no callable API. You enable it by adding it to the `modules` array of your Nuxt config and configure it via the `workflow` key.
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
@@ -23,11 +23,11 @@ export default defineNuxtConfig({
|
|
|
23
23
|
When enabled, the module:
|
|
24
24
|
|
|
25
25
|
- Registers the [`workflow/nitro`](/docs/api-reference/workflow-nitro) module on Nuxt's Nitro server, which transforms `"use workflow"` and `"use step"` directives, builds the workflow bundles, and registers the workflow runtime routes under `/.well-known/workflow/v1/`.
|
|
26
|
-
- Configures Vite to bundle (rather than externalize) the Workflow SDK packages in SSR mode so workflow code is transformed correctly.
|
|
27
|
-
- Enables the `workflow` TypeScript plugin by default for IDE IntelliSense.
|
|
26
|
+
- Configures Vite to bundle (rather than externalize) the Workflow SDK packages in server-side rendering (SSR) mode so workflow code is transformed correctly.
|
|
27
|
+
- Enables the `workflow` TypeScript plugin by default for integrated development environment (IDE) IntelliSense.
|
|
28
28
|
- Uses Nuxt/Nitro's detected `workspaceDir` so monorepo apps can import sibling workspace packages without extra workflow config.
|
|
29
29
|
|
|
30
|
-
## Module
|
|
30
|
+
## Module options
|
|
31
31
|
|
|
32
32
|
Options are read from the `workflow` key of your Nuxt config. The option type is exported as `ModuleOptions`:
|
|
33
33
|
|
|
@@ -8,7 +8,7 @@ related:
|
|
|
8
8
|
- /docs/api-reference/workflow-observability/observability-revivers
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
Hydrates (deserializes) a single value that was stored by the workflow runtime. This is the lower-level building block behind [`hydrateResourceIO()`](/docs/api-reference/workflow-observability/hydrate-resource-io)
|
|
11
|
+
Hydrates (deserializes) a single value that was stored by the workflow runtime. This is the lower-level building block behind [`hydrateResourceIO()`](/docs/api-reference/workflow-observability/hydrate-resource-io). Use it when you have a raw serialized value rather than a whole resource, such as a single field from an event payload.
|
|
12
12
|
|
|
13
13
|
```typescript lineNumbers
|
|
14
14
|
import { hydrateData, observabilityRevivers } from "workflow/observability"; // [!code highlight]
|
|
@@ -17,7 +17,7 @@ declare const serialized: unknown; // @setup
|
|
|
17
17
|
const value = hydrateData(serialized, observabilityRevivers); // [!code highlight]
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
## API
|
|
20
|
+
## API signature
|
|
21
21
|
|
|
22
22
|
### Parameters
|
|
23
23
|
|
|
@@ -30,6 +30,6 @@ const value = hydrateData(serialized, observabilityRevivers); // [!code highligh
|
|
|
30
30
|
|
|
31
31
|
The hydrated plain JavaScript value. The input is handled by shape:
|
|
32
32
|
|
|
33
|
-
- Format-prefixed binary data (`Uint8Array`) is decoded and parsed from the [devalue](https://github.com/Rich-Harris/devalue) format
|
|
34
|
-
- Encrypted data is returned as-is (a raw `Uint8Array`)
|
|
35
|
-
- Already-plain values (numbers, strings, `null`) are returned unchanged
|
|
33
|
+
- Format-prefixed binary data (`Uint8Array`) is decoded and parsed from the [devalue](https://github.com/Rich-Harris/devalue) format.
|
|
34
|
+
- Encrypted data is returned as-is (a raw `Uint8Array`). See [Encrypted data](/docs/api-reference/workflow-observability#encrypted-data).
|
|
35
|
+
- Already-plain values (numbers, strings, and `null`) are returned unchanged.
|