Moose provides multiple layers of error protection, both at the workflow and task level:
Moose automatically catches any runtime errors during workflow execution. Errors are logged for debugging, and the orchestrator will retry failed tasks according to the retries option.
In your Workflow, you can configure the following options to control workflow behavior, including timeouts and retries:
import { Task, Workflow } from "@514labs/moose-lib"; export const myworkflow = new Workflow("myworkflow", { startingTask: task1, retries: 1, timeout: "10m",});For more granular control over task-level errors and retries, you can configure your individual tasks to have their own retry behavior.
For workflows & tasks that may not have a predefined timeout, you may set never as the timeout.
import { Task, Workflow } from "@514labs/moose-lib"; export const task1 = new Task<Foo, void>("task1", { run: async (ctx) => {}, retries: 1, timeout: "5m"}); export const myworkflow = new Workflow("myworkflow", { startingTask: task1, retries: 2, timeout: "10m",});When configuring retries, it's important to understand how workflow-level and task-level retries interact. Consider the following scenario:
import { Task, Workflow } from "@514labs/moose-lib"; export const task1 = new Task<Foo, void>("task1", { run: async (ctx) => {}, retries: 3,}); export const myworkflow = new Workflow("myworkflow", { startingTask: task1, retries: 2,});If the execution of the workflow encounters an error, the retry sequence would proceed as follows:
Workflow Attempt 1
Workflow Attempt 2
In this example, the workflow will make a total of 2 attempts, and each task within those attempts will retry up to 3 times before the workflow itself retries.