Analysis & Visualization
Introspect a workflow run's DAG — dependencies, levels, critical path, and stats.
Introspect a workflow run's DAG — dependencies, levels, critical path, and stats.
queue.workflows.analyze(runId) returns a WorkflowAnalysis — a read-only view
over the run's graph (dag()) and per-node statuses (nodes()). Every method is
pure graph computation over that snapshot, so it works whether the run is pending,
in flight, or finished.
const a = queue.workflows.analyze(runId);
if (!a) throw new Error("unknown run");a.roots(); // ["extract"] — nodes with no dependencies
a.leaves(); // ["load"] — nodes nothing depends on
a.ancestors("load"); // upstream — transitive predecessors
a.descendants("extract"); // downstream
a.topologicalOrder(); // a valid execution order (throws on a cycle)topologicalLevels() groups nodes by dependency depth — everything in one level
can run in parallel. criticalPath() returns the longest dependency chain from a
root to a leaf (the structural lower bound on how many sequential steps the run
takes).
a.topologicalLevels(); // [["extract"], ["transform-a", "transform-b"], ["load"]]
a.criticalPath(); // ["extract", "transform-a", "load"]a.stats();
// { total: 4, byStatus: { completed: 3, running: 1 }, completed: 3, failed: 0, running: 1, pending: 0 }analyze and wait are separate calls, not
chainable: analyze(runId) returns a snapshot now, while handle.wait()
resolves when the run finishes. Re-call analyze(runId) after wait() to see
the slowest chain on the completed run.