From 3c03916abfe81af65f03f1b3a5b3d8676c532046 Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Mon, 17 Feb 2025 18:31:20 +0000 Subject: [PATCH 1/2] Multiple minor updates --- src/content/docs/workflows/build/sleeping-and-retrying.mdx | 6 +++--- src/content/docs/workflows/build/trigger-workflows.mdx | 6 +++--- src/content/docs/workflows/build/workers-api.mdx | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/content/docs/workflows/build/sleeping-and-retrying.mdx b/src/content/docs/workflows/build/sleeping-and-retrying.mdx index 13f9a90f29ae7b7..bb8dd0238fc0f9b 100644 --- a/src/content/docs/workflows/build/sleeping-and-retrying.mdx +++ b/src/content/docs/workflows/build/sleeping-and-retrying.mdx @@ -26,7 +26,7 @@ Use `step.sleep` to have a Workflow sleep for a relative period of time: await step.sleep("sleep for a bit", "1 hour") ``` -The second argument to `step.sleep` accepts both `number` (seconds) or a human-readable format, such as "1 minute" or "26 hours". The accepted units for `step.sleep` when used this way are as follows: +The second argument to `step.sleep` accepts both `number` (milliseconds) or a human-readable format, such as "1 minute" or "26 hours". The accepted units for `step.sleep` when used this way are as follows: ```ts | "second" @@ -48,7 +48,7 @@ const workflowsLaunchDate = Date.parse("24 Oct 2024 13:00:00 UTC"); await step.sleepUntil("sleep until X times out", workflowsLaunchDate) ``` -You can also provide a Unix timestamp (seconds since the Unix epoch) directly to `sleepUntil`. +You can also provide a Unix timestamp (milliseconds since the Unix epoch) directly to `sleepUntil`. ## Retry steps @@ -69,7 +69,7 @@ const defaultConfig: WorkflowStepConfig = { When providing your own `StepConfig`, you can configure: -* The total number of attempts to make for a step +* The total number of attempts to make for a step (accepts `Infinity` for unlimited retries) * The delay between attempts (accepts both `number` (ms) or a human-readable format) * What backoff algorithm to apply between each attempt: any of `constant`, `linear`, or `exponential` * When to timeout (in duration) before considering the step as failed (including during a retry attempt) diff --git a/src/content/docs/workflows/build/trigger-workflows.mdx b/src/content/docs/workflows/build/trigger-workflows.mdx index 75cb13b25b2aec5..0ad4094885a9350 100644 --- a/src/content/docs/workflows/build/trigger-workflows.mdx +++ b/src/content/docs/workflows/build/trigger-workflows.mdx @@ -144,14 +144,14 @@ Calling `resume` on an instance that is not currently paused will have no effect ### Stop a Workflow -You can stop a Workflow instance by calling `abort` against a specific instance ID. +You can stop/terminate a Workflow instance by calling `terminate` against a specific instance ID. ```ts let instance = await env.MY_WORKFLOW.get("abc-123") -await instance.abort() // Returns Promise +await instance.terminate() // Returns Promise ``` -Once stopped, the Workflow instance *cannot* be resumed. +Once stopped/terminated, the Workflow instance *cannot* be resumed. ### Restart a Workflow diff --git a/src/content/docs/workflows/build/workers-api.mdx b/src/content/docs/workflows/build/workers-api.mdx index 215f4fc48abdc39..8e0d2136195b65b 100644 --- a/src/content/docs/workflows/build/workers-api.mdx +++ b/src/content/docs/workflows/build/workers-api.mdx @@ -47,6 +47,8 @@ The `WorkflowEvent` type accepts an optional [type parameter](https://www.typesc Refer to the [events and parameters](/workflows/build/events-and-parameters/) documentation for how to handle events within your Workflow code. +Finally, any JS control-flow primitive (if conditions, loops, try-catches, promises, etc) can be used to manage steps inside the `run` method. + ## WorkflowEvent ```ts From 7d18dc2f900ff5fcab0cbbd3838b0fa1e1df943a Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Mon, 17 Feb 2025 18:36:52 +0000 Subject: [PATCH 2/2] Update src/content/docs/workflows/build/sleeping-and-retrying.mdx Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com> --- src/content/docs/workflows/build/sleeping-and-retrying.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/workflows/build/sleeping-and-retrying.mdx b/src/content/docs/workflows/build/sleeping-and-retrying.mdx index bb8dd0238fc0f9b..5953adee16e44af 100644 --- a/src/content/docs/workflows/build/sleeping-and-retrying.mdx +++ b/src/content/docs/workflows/build/sleeping-and-retrying.mdx @@ -48,7 +48,7 @@ const workflowsLaunchDate = Date.parse("24 Oct 2024 13:00:00 UTC"); await step.sleepUntil("sleep until X times out", workflowsLaunchDate) ``` -You can also provide a Unix timestamp (milliseconds since the Unix epoch) directly to `sleepUntil`. +You can also provide a UNIX timestamp (milliseconds since the UNIX epoch) directly to `sleepUntil`. ## Retry steps