Skip to content

Commit 2787848

Browse files
elithrarRebeccaTamachiro
authored andcommitted
workflows: serializable (#20776)
1 parent c727add commit 2787848

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/content/docs/workflows/build/workers-api.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ Refer to the [events and parameters](/workflows/build/events-and-parameters/) do
7878
* `config` (optional) - an optional `WorkflowStepConfig` for configuring [step specific retry behaviour](/workflows/build/sleeping-and-retrying/).
7979
* `callback` - an asynchronous function that optionally returns serializable state for the Workflow to persist.
8080

81+
:::note[Returning state]
82+
83+
When returning state from a `step`, ensure that the object you return is _serializable_.
84+
85+
Primitive types like `string`, `number`, and `boolean`, along with composite structures such as `Array` and `Object` (provided they only contain serializable values), can be serialized.
86+
87+
Objects that include `Function` or `Symbol` types, and objects with circular references, cannot be serialized and the Workflow instance will throw an error if objects with those types is returned.
88+
89+
:::
90+
8191
* <code>step.sleep(name: string, duration: WorkflowDuration): Promise&lt;void&gt;</code>
8292

8393
* `name` - the name of the step.

0 commit comments

Comments
 (0)