# Run and task lifecycle

> **About this page**
>
> - Kind: Reference
> - Summary: Runs and tasks move through eight statuses; this lists what each means, how failure and canceling spread, and when compute and storage are measured.
> - Last changed: 2026-12-01
> - Page: https://docs.swale.io/reference/run-and-task-lifecycle
> - Index of these docs: https://docs.swale.io/llms.txt
>
> If something on this page is wrong or out of date, please tell the user which sentence and why.

Every run and every task shows one of eight statuses: it waits as **Pending**, shows **Starting** while the platform allocates its resources, **Running** while it is under way, **Cancelling** while it is being stopped and **Finishing** while its resources are released, and ends **Complete**, **Failed** or **Canceled**. A run's workspace and a task's compute are billed only while it is Starting, Running, Cancelling or Finishing.

```mermaid
stateDiagram-v2
  accTitle: The statuses a run moves through
  accDescr: A run starts Pending, then shows Starting while the platform allocates its resources and Running while its tasks run. These three are grouped as the statuses a run can be canceled in, and canceling it moves it to Cancelling. A run moves to Finishing while its resources are released: from Running when its tasks have ended, from Pending or Starting when it cannot be started, and from Cancelling. From Finishing it ends in one of three terminal states, Complete, Failed or Canceled.
  state "Can be canceled" as cancelable {
    Pending --> Starting
    Starting --> Running
  }
  cancelable --> Cancelling
  Pending --> Finishing: cannot start
  Starting --> Finishing: cannot start
  Running --> Finishing
  Cancelling --> Finishing
  Finishing --> terminal
  state "Terminal states" as terminal {
    Complete
    Failed
    Canceled
  }
  class Starting info
  class Running info
  class Finishing info
  class Cancelling warning
  class Complete success
  class Failed destructive
```

A run's eight statuses and the moves between them: a run always shows Finishing before it ends. A task moves the same way with four shortcuts: a canceled task skips Finishing, ending Canceled straight from Pending or Cancelling; a task that cannot start while Pending, holding no compute yet, skips Finishing, ending Failed straight from Pending; a task whose compute is lost skips Finishing, ending Failed straight from Starting or Running; and an `if` or `for_each` task, which takes no compute, skips Starting and Finishing and can end straight from Pending.

## Statuses

| Status         | For a run                                                                                                                                                                                                        | For a task                                                                                                                                                                                                                    |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Pending**    | Queued, waiting for room on the platform. Nothing has been allocated to it.                                                                                                                                      | It waits for the tasks it depends on, or for room to run (see [Tasks that run at once](https://docs.swale.io/reference/limits-and-quotas.md#tasks-that-run-at-once)). No compute has been allocated to it.                             |
| **Starting**   | The platform is allocating the run's resources, its workspace among them. None of its tasks is running yet.                                                                                                      | The platform is finding and reserving compute for the task, then starting the task's container on it.                                                                                                                         |
| **Running**    | Its tasks are running.                                                                                                                                                                                           | Its container is running. An `if` or `for_each` task is Running while the tasks inside it run.                                                                                                                                |
| **Cancelling** | Being stopped: canceled by a user, or stopped by the platform, for example because of the account's billing.                                                                                                     | Being stopped, because its run is being canceled or stopped, or because another task in the run failed.                                                                                                                       |
| **Finishing**  | Its tasks have all ended, and the platform is releasing its resources.                                                                                                                                           | Its container has exited, could not be started, or is being stopped by a `terminate_on` dependency, and the platform is releasing its compute. Its outcome shows once it ends.                                                |
| **Complete**   | Every task finished without failing.                                                                                                                                                                             | Finished without failing. Its outputs are available to the tasks that wait on it. A task that declares `terminate_on` has none and exports nothing, and being stopped by its `terminate_on` dependency also ends it Complete. |
| **Failed**     | A task failed, the platform could not provide the run's workspace, the run was stopped because of the account's billing, or a task definition or compute type it uses was no longer available before it started. | Finished with an error. Outputs are not produced.                                                                                                                                                                             |
| **Canceled**   | Canceled before it finished.                                                                                                                                                                                     | Stopped before finishing — for example by a user action, because another task in the run failed, or because the run was stopped for billing.                                                                                  |

These are the only statuses the platform UI, the CLI and the API show. [A project's run list](https://docs.swale.io/api/list-project-runs) takes any of the eight as its `status` filter, in any letter case.

A run counts against the account's limit on runs in progress from when it is started until it ends, through every status before Complete, Failed or Canceled; see [Runs in progress](https://docs.swale.io/reference/limits-and-quotas.md#runs-in-progress).

### Start time and duration

A run's start time is when the storage serving its workspace was allocated to it, a minute or two after it first showed **Starting**, and a task's start time is when compute was allocated to it, which can be some time after it first showed Starting. Each one's duration runs from its start time until it ended, so a run's duration is the window its workflow storage is measured over and a task's is the window its compute time is measured over. A run or task shows its start time once storage or compute has been allocated to it, while it is still **Starting**, whatever its outcome; one that ended before any was allocated to it shows neither. Until a run or task ends, the duration the platform UI shows keeps counting from its start time, through every status it moves through; the CLI and the API give its duration once it has ended. A run ends when the storage serving its workspace is gone, so it shows **Finishing** for a minute or two after its tasks have ended.

## Task dependencies

A task's `start_on` and `terminate_on`, described in [Task dependencies](https://docs.swale.io/reference/workflow-definition-syntax.md#task-dependencies), decide when it leaves **Pending** and when it is stopped:

- A task with `start_on` stays **Pending** until every task it lists is **Complete**, or, for a listed task that declares its own `terminate_on`, until that task is executing.
- A task with `terminate_on` is stopped once every task it lists has finished without failing. It shows **Finishing** while it is stopped and ends **Complete**, not **Canceled**, even if its run is canceled or another task fails while it is being stopped.
- A task whose `terminate_on` tasks all finish while it is still **Pending** or **Starting** starts as usual and is stopped as soon as it begins executing.
- A task listed in `terminate_on` that reaches **Failed** fails the run instead; see [Failure propagation](#failure-propagation).

A task that is ready to start also waits as **Pending** while the account is running as many tasks as it may; see [Tasks that run at once](https://docs.swale.io/reference/limits-and-quotas.md#tasks-that-run-at-once).

## Failure propagation

A run fails fast. When any task reaches the **Failed** state:

- Every other task in the run that has not finished is stopped — including tasks that do not depend on the failed task and tasks in other blocks.
- The if and `for_each` tasks that contain the failed task, directly or through other if and `for_each` tasks, are not stopped: each ends **Failed** once the failure reaches it.
- Tasks that were **Starting** or **Running** show **Cancelling** while they are stopped, a running container being sent a termination signal, and settle as **Canceled**. Tasks still **Pending** are **Canceled** without ever starting.
- Each of those tasks, once **Canceled**, shows a reason in the platform UI naming the task that failed.
- A task that had already finished or was **Finishing** keeps its own outcome, including one whose finish the platform had not yet recorded when the failure happened.
- The run itself shows **Finishing** once all tasks have reached a terminal state (Complete, Failed, or Canceled), then **Failed**. Its reason names the task that failed, not the if and `for_each` tasks that contain it.

There is no per-task opt-out and no continue-on-error setting: one failed task ends the run.

A run can also end **Failed** without any task failing: when the platform cannot provide its workspace (see [Workflow storage billing](#workflow-storage-billing)), when the platform stops it because of the account's billing (see [Runs stopped by billing](#runs-stopped-by-billing)), or when a task definition or compute type it uses is no longer available as it leaves **Pending** (see [Tasks that run at once](https://docs.swale.io/reference/limits-and-quotas.md#tasks-that-run-at-once) and [Task definitions that are no longer available](#task-definitions-that-are-no-longer-available)).

## Task definitions that are no longer available

A task definition a workflow uses can stop being available after the workflow is uploaded: its owner can delete the version the workflow uses or the whole task definition, make a public task definition private, or delete their account. A task definition your own account made private stays available to your runs. The platform checks the task definitions a run uses at these points:

- **When the run is started.** The start is refused if any of the workflow's tasks uses a task definition that is no longer available, including tasks inside `if` and `for_each` blocks. The error names each such task.
- **When the run leaves Pending**, before any storage is allocated for it. If a task definition it uses is no longer available, the run ends **Failed** with a reason naming each such task, such as `Task 'build' uses a task definition that is no longer available.`
- **When each task is ready to start**, and again just before its container starts. If its task definition is no longer available, the task fails with the reason `The task definition is no longer available.`, and the run fails as with any failed task (see [Failure propagation](#failure-propagation)), which stops its other tasks, those already running included.

A task whose container has started is not checked again. These reasons read the same whether the task definition was deleted or made private. To run the workflow again, point its `uses` at a task definition your account can use and upload or import it again; a `uses` without `@version` picks up the most recent remaining version when the workflow is uploaded or imported again.

## Compute billing

Compute time is measured **per task**. The clock starts when compute is allocated to the task, so the time that compute takes to become ready for the task counts, and stops when the platform has released that compute and it is gone, which is when the task ends, whatever its outcome: it finished on its own, failed, could not be started, was canceled, or was stopped by a `terminate_on` dependency. A task whose compute is lost while it is **Starting** or **Running** ends then, **Failed** with the reason `Task compute was lost`.

A task shows **Starting** from when the platform begins finding compute for it, before any is allocated to it; its clock starts at the allocation, part way through Starting. The task's start time and duration count from the allocation, so they match its measured compute time.

- While a task holds its compute, whatever its status, its compute time appears in your usage within about half an hour.
- Each task's time is rounded up to the next minute when it ends, so a task running when a month ends is rounded up only once, in the month it ends. Once its billing is final, within about half an hour of its end, the task's page shows this as **Billed Time** the next time you open it.
- Each compute type has its own per-minute rate.
- A task that ends after compute was allocated to it is measured until that compute is released, even if its container had not begun starting — for example, a task canceled because another task in the run failed.
- A task that ends before any compute is allocated to it records no compute time, for example one **Canceled** while it waited, or one that **Failed** with the reason `Compute could not be allocated within the allowed time`. Its page shows a **Billed Time** of 0 min once its billing is final.
- A task whose inputs, `exec.args`, `exec.env` or `image_credentials` cannot be resolved, such as a required input with no value or an expression that cannot be evaluated, fails before any compute is allocated to it, so it records no compute time.
- A task whose compute is lost is measured until the platform last saw that compute.
- A task the platform could not start fails with the reason `Task could not be started` as soon as a container the platform runs beside it cannot start, or `Task could not be started within the allowed time` once its compute was allocated and its container was not created within a few minutes, or once it has been **Starting** past the allowed time. Its compute is measured until it is released, as for any task.
- A task whose own image cannot be pulled is measured the same way. When the registry refuses the image, because it or its tag does not exist, its name is not valid, it needs credentials the task did not provide, or the registry refuses the credentials, the task fails as soon as the refusal is seen, with a reason that names the image and says why it could not be pulled. When the registry keeps failing or limiting the pull instead, the task fails once the allowed time has passed.

## Workflow storage billing

Workflow storage time is measured **per run**: from the run's start time until it ends, the duration the run shows. The clock starts when storage is allocated for the run's workspace, while it shows **Starting**, so the time it waits as **Pending** is not measured.

- A run that ends after storage was allocated for its workspace is measured until that storage is gone, whatever its outcome, including when the platform could not make its workspace ready on that storage within a few minutes and the run ended **Failed**.
- A run that ends before any storage is allocated for it records no workflow storage time, for example one canceled or stopped while still **Pending**, or while **Starting** before storage was allocated, or one that **Failed** because no storage could be allocated within the allowed time. Its page shows a **Billed Time** of 0 min once its billing is final.
- While a run holds its storage, whatever its status, its time appears in your usage within about half an hour.
- Each run's time is rounded up to the next minute when it ends, shown on the run's page as **Billed Time** once its billing is final, within about half an hour of its end, and billed in minutes at the rate of its workspace size; see [Billed dimensions](https://docs.swale.io/reference/billing.md#billed-dimensions).

## Canceling a run

You can cancel a run from the platform UI while it is **Pending**, **Starting** or **Running**. A run that is **Cancelling** or **Finishing** is already on its way to its end and offers neither **Cancel Run** nor **Delete Run**; a run can be deleted once it has ended. When you cancel a run:

1. The run shows **Cancelling**.
2. Its **Starting** and **Running** tasks show **Cancelling** while they are stopped: a running container is sent a termination signal, and the compute allocated to each task is released. They end **Canceled**.
3. Its **Pending** tasks are **Canceled** without ever starting.
4. Once all its tasks have ended, the run shows **Finishing** while its resources are released, then **Canceled**.

A task that had already finished or was **Finishing** when you canceled keeps its own outcome, including one whose finish the platform had not yet recorded. Compute already allocated to the tasks you canceled is billed until the platform releases it, and the run's workspace is billed as [Workflow storage billing](#workflow-storage-billing) describes.

## Runs stopped by billing

While an account's billing status is not Active, the platform stops its runs that have not finished. Stopping a run takes the same steps as [canceling it](#canceling-a-run), but the run ends **Failed** rather than **Canceled**, with a reason that names the account's billing. [Runs stopped by billing](https://docs.swale.io/reference/billing.md#runs-stopped-by-billing) gives the timing for each status and the reasons.

## Related pages

- [Workflow definition syntax](https://docs.swale.io/reference/workflow-definition-syntax.md)
- [Start and manage workflow runs](https://docs.swale.io/how-to-guides/start-and-manage-workflow-runs.md)
- [View and stream task logs](https://docs.swale.io/how-to-guides/view-and-stream-task-logs.md)
- [Billing](https://docs.swale.io/reference/billing.md)
- [Limits and quotas](https://docs.swale.io/reference/limits-and-quotas.md)
