Skip to content

buildExecutionTimeline

function buildExecutionTimeline(params): ExecutionTimeline;

Defined in: src/execution.ts:867

Replay an execution history as an ordered list of state runs: what ran, in what order, for how long, and how each run ended.

Where parseExecutionHistory folds a state’s runs into one result, this keeps them apart — every Retry attempt, every Map iteration and every pass through a Parallel branch is its own TimelineEntry, in the order the execution entered them. That is what a scrubber, a Gantt view or a “what ran when” report needs.

Pure and deterministic; it reads the history and nothing else.

BuildExecutionTimelineParams

Object parameters

ExecutionTimeline

The ordered timeline, with the run’s overall window and status

import { buildExecutionTimeline } from 'sfn-diagram';
const timeline = buildExecutionTimeline({ definition: asl, events });
for (const entry of timeline.entries) {
console.log(entry.stateName, entry.attempt, entry.status);
}

A container entry’s branchCount / iterationCount counts what the history shows starting inside it. A Distributed Map runs its iterations as child executions, whose events are not in this history at all, so its count is 0 — the parent history has nothing finer than the run’s own outcome to offer.

An entry is running only if it never closed: on a finished execution that means the state the run was still inside when it ended.