1. MooseStack
  2. Moose Workflows
  3. Retries and Timeouts

Error Detection and Handling

Moose provides multiple layers of error protection, both at the workflow and task level:

Workflow-Level Retries and Timeouts

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:

app/index.ts
import { Task, Workflow } from "@514labs/moose-lib"; export const myworkflow = new Workflow("myworkflow", {  startingTask: task1,  retries: 1,  timeout: "10m",});

Task-Level Errors and Retries

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.

app/index.ts
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",});

Example: Workflow and Task Retry Interplay

When configuring retries, it's important to understand how workflow-level and task-level retries interact. The retries value specifies the number of retry attempts after the initial execution fails.

Consider the following scenario:

  • Workflow retries: 1 (1 initial + 1 retry = 2 total attempts)
  • Task retries: 2 (1 initial + 2 retries = 3 total attempts)
app/index.ts
import { Task, Workflow } from "@514labs/moose-lib"; export const task1 = new Task<Foo, void>("task1", {  run: async (ctx) => {},  retries: 2,}); export const myworkflow = new Workflow("myworkflow", {  startingTask: task1,  retries: 1,});

If the task keeps failing, the retry sequence would proceed as follows:

  1. Workflow Attempt 1

    • Task Attempt 1 (initial): Task fails
    • Task Retry 1: Task fails
    • Task Retry 2: Task fails
    • Workflow attempt fails after exhausting task retries
  2. Workflow Retry 1

    • Task Attempt 1 (initial): Task fails
    • Task Retry 1: Task fails
    • Task Retry 2: Task fails
    • Workflow fails after exhausting all retries

This results in up to 6 total task executions: 3 task attempts × 2 workflow attempts.

On this page

Workflow-Level Retries and TimeoutsTask-Level Errors and RetriesExample: Workflow and Task Retry Interplay
FiveonefourFiveonefour
Fiveonefour Docs
MooseStackTemplatesGuides
Release Notes
Source523
  • Overview
Build a New App
  • 5 Minute Quickstart
  • Browse Templates
  • Existing ClickHouse
Add to Existing App
  • Next.js
  • Fastify
Fundamentals
  • Moose Runtime
  • MooseDev MCP
  • Data Modeling
Moose Modules
  • Moose OLAP
  • Moose Streaming
  • Moose Workflows
    • Define Workflows
    • Scheduling
    • Triggers
    • Retries and Timeouts
    • Cancelling Running Workflows
  • Moose APIs & Web Apps
Deployment & Lifecycle
  • Moose Migrate
  • Moose Deploy
Reference
  • API Reference
  • Data Types
  • Table Engines
  • CLI
  • Configuration
  • Observability Metrics
  • Help
  • Release Notes
Contribution
  • Documentation
  • Framework
app/index.ts
import { Task, Workflow } from "@514labs/moose-lib"; export const myworkflow = new Workflow("myworkflow", {  startingTask: task1,  retries: 1,  timeout: "10m",});
app/index.ts
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",});
  • Workflow retries: 1 (1 initial + 1 retry = 2 total attempts)
  • Task retries: 2 (1 initial + 2 retries = 3 total attempts)
app/index.ts
import { Task, Workflow } from "@514labs/moose-lib"; export const task1 = new Task<Foo, void>("task1", {  run: async (ctx) => {},  retries: 2,}); export const myworkflow = new Workflow("myworkflow", {  startingTask: task1,  retries: 1,});