Aviary

CLI

Inspect, cancel and export workflow runs from the terminal — `durable inspect` (including the `--stale` stranded-run view), `durable cancel`, `durable export` for CI replay fixtures, and `durable lifecycle:republish`.

@dudousxd/nestjs-durable-cli gives you durable inspect and durable cancel — a quick look at runs and their step timelines, and a way to stop one, without opening the dashboard.

pnpm add -D @dudousxd/nestjs-durable-cli

Point it at your store

The CLI reads from a durable.config.{mjs,js,cjs} in your project. Export your already-configured store as store, or as the default export:

durable.config.mjs
import { MikroOrmStateStore } from '@dudousxd/nestjs-durable-store-mikro-orm';
import { buildOrm } from './src/orm';

export const store = new MikroOrmStateStore(await buildOrm());

A default export works too — either the store itself, or an object with a store property (e.g. export default { store }). The CLI checks store, then default.store, then default, in that order, and errors if none of them is a StateStore.

Use it

durable inspect                  # list recent runs
durable inspect wrun_8Kb2        # show one run's step timeline
durable inspect --status failed  # filter the list
RUN        WORKFLOW  STATUS     UPDATED
wrun_8Kb2  checkout  running    3s ago
wrun_Qz71  onboarding failed    2m ago
checkout  [completed]  v1
wrun_8Kb2

  0  reserveStock          (local)              completed  150ms
  1  payments.charge-card  (remote @payments)   completed  750ms  ×2
  2  sleep                 (sleep)              completed  3.0s
  3  shipping.dispatch     (remote @logistics)  completed  800ms

Reading the output:

  • ×2 after a step's duration is an attempt count — it only shows up once a step has retried (attempts > 1); a step that succeeded on its first try has no suffix.
  • @payments / @logistics is the worker group the step ran on, shown only for steps that recorded one.
  • Timestamps in the runs list (UPDATED) are relative — seconds/minutes/hours/days ago, rounded to the coarsest unit that fits (3s ago, 2m ago, 4h ago, 1d ago).
OptionDescription
--status <status>running / suspended / completed / failed / cancelled
--limit <n>max runs to list (default 50)
--stale[=<duration>]only the runs that look stranded, idle at least <duration> (default 15m). See below.
--namespace <ns>restrict the listing to one namespace
--config <path>path to the config (default: ./durable.config.{mjs,js,cjs})

Find stranded runs

durable inspect --stale              # idle 15 minutes or more
durable inspect --stale=1h           # your own threshold: ms, s, m, h or d (90s, 15m, 4h, 2d)
durable inspect --stale --namespace tenant-a
RUN        WORKFLOW  STATUS     IDLE    WHY
wrun_8Kb2  pipeline  suspended  4h12m   step 2 charge pending 4h12m (attempt 1)
wrun_Qz71  onboard   suspended  52m0s   suspended, no wake timer

--stale lists the running/suspended runs that are either suspended with no wake timer, or parked on an old pending remote step that nothing is leasing (no timeoutMs, heartbeat or remoteRedispatchMs lease in the future). It is the same query as engine.listStalledRuns() and the stalled-run pager, run as findStalledRuns(store, ...) against your configured store. It inspects up to 1000 in-flight runs and prints at most --limit. An unparseable duration (--stale=15mins) exits 1.

Export a replay fixture

durable export wrun_8Kb2 --out test/fixtures/pipeline-wrun_8Kb2.json
durable export wrun_8Kb2 > fixture.json   # or to stdout

export writes the run row and its full checkpoint timeline as a JSON fixture ({ version: 1, run, checkpoints }, the format of the testing kit's serializeRunHistory). Commit it and assert it in CI with assertReplayable(register, parseRunHistory(json)): a code change that renames, reorders or removes a step at a position the run already recorded then fails the build instead of breaking an in-flight run on deploy. See Testing → Replay a captured run in CI. An unknown run exits 1.

A fixture holds the run's payloads

The fixture contains the run's input, outputs, step logs and errors exactly as the store returns them. If your durable.config wraps the store in a CodecStateStore, they come out decoded. Scrub anything sensitive before committing it.

Cancel a run

durable cancel wrun_8Kb2

This marks the run cancelled in the store — a suspended run won't resume, and the recovery/timer poller skips it going forward. --config applies here too, same as inspect.

It's a soft cancel, not a hard kill: if a step is already in flight on some worker, that worker finishes its current attempt before it next checks the run's status, so cancellation is observed at the next checkpoint rather than interrupting execution mid-step. Cancelling a run that's already completed, failed, or cancelled is a no-op — the CLI tells you it's already terminal and leaves it alone.

Republish lifecycle events

durable lifecycle:republish --workflow ingestion --since 2026-11-01 --subscriber refresh-summaries
durable lifecycle:republish --run wrun_8Kb2

Publishes settled runs' lifecycle events again, starting the subscribers that have not started from them: a subscriber added after the runs settled, or one that failed to start. --run takes one run; --workflow takes its settled runs, bounded by --since / --until (ISO dates, compared with when each run settled) and --limit (default 1000). --subscriber restricts it to one subscribing workflow. It prints how many runs it published, how many subscriber runs it started, and each failure.

The subscribers' where and input run in the CLI's process, so this command needs an engine, not only a store: export it as engine from the same config, with the subscribing workflows registered.

durable.config.mjs
export const store = new MikroOrmStateStore(await buildOrm());
export const engine = new WorkflowEngine({ store });
engine.register('refresh-summaries', '1', refreshSummaries, {
  onEvent: [runCompletedEvent('ingestion')],
});

Migrate code from @nestjs/workflows

durable migrate nestjs-workflows 'src/**/*.ts' --dry-run
durable migrate nestjs-workflows 'src/**/*.ts'

Rewrites the files that import @nestjs/workflows to nestjs-durable where the mapping is 1:1, and leaves // TODO(durable-migrate): … above what it can't map. It needs no config or store. See Migrating from @nestjs/workflows for the mapping and the cutover.

Usage and exit codes

Running durable with no subcommand, or an unrecognized one, prints the usage text instead of doing anything:

durable            # prints usage, exits 0
durable frobnicate  # prints usage, exits 1 (unknown subcommand)

On this page