Skip to the content.

Concepts

Steady has a small vocabulary. This page explains each term and how they fit together. For exact signatures see the API reference; for the precise rules see Guarantees.

How Steady runs a flow

Flow

A flow is an async function with a name, registered on a Steady instance:

const invoice = steady.defineFlow("monthly-invoice", async (f, input: { customerId: string }) => {
  const lines = await f.step("collect-usage", () => usage(input.customerId))
  const pdf = await f.step("render", () => renderPdf(lines))
  await f.step("send", () => mail(input.customerId, pdf.url))
  return { lines: lines.length }
})

The function receives a context f and the run input. Everything that has a side effect or reads the outside world goes inside f.step. The flow’s return value becomes the run output.

Flow names are 1 to 64 characters of a-z, 0-9, ., _ and -, starting with a letter or digit. A name is unique per instance: defining a second flow with the same name throws FlowDefinitionError. Only defined flows can be started, scheduled or signalled by flow and key (the registry check), and a runner only claims runs of flows it has defined.

Run

A run is one execution of a flow with one input. It is a row in steady_runs and moves through these statuses:

pending --> running --> completed
   ^           |    +--> failed      (dead letter, error text kept)
   |           +-------> sleeping --+
   |           +-------> waiting  --+ (wake time reached or signal arrived)
   |           +-------> pending  --+ (retry backoff: pending with a future wake time)
   +--------------------------------+
any unfinished status --> cancelled

steady.start(flow, input, { key }) creates a run. With a key, the run is unique per (tenant, flow, key): starting again returns the existing run untouched (created: false). Use keys for anything that must happen once per business event, such as invoice:2026-11:cust_42.

Step and the journal

f.step(name, fn, options?) runs fn and records its result. The recorded results of a run, in order, are its journal. When a run resumes (after a sleep, a wait, a retry or a crash), Steady calls the flow function again from the top. Each f.step call whose position is already in the journal returns the recorded value without running fn; the first call past the journal runs for real. This is replay.

Consequences:

A step can carry a retry policy ({ retry: { maxAttempts, backoffMs, maxBackoffMs, nonRetryable } }) and can be marked { sensitive: true } (see Security).

Sleep

await f.sleep("2d") parks the run: it records the wake time, releases the lease and the process moves on. A later tick at or after the wake time resumes the flow, which replays up to the sleep and continues. Durations are milliseconds (number), digit strings, unit strings such as "500ms", "30s", "20m", "2h", "2d", "1w", combinations like "1h30m", or a Date for “until”.

Signals

A signal is a named message to a run: steady.signal(target, name, payload?). The target is a run id or { flow, key }. The payload defaults to true, so if (await f.waitForSignal("approved")) works without one.

await f.waitForSignal(name, { timeout }) returns the payload of the oldest eligible signal with that name, or parks the run until one arrives. With a timeout, it returns null when the deadline passes first. Signals sent before the flow reaches the wait are buffered (up to 1,000 unconsumed per run) and consumed in arrival order.

A signal still unconsumed when a wait times out, or arriving after that, is late: it is kept and visible in history(), but a later wait with the same name ignores it unless it passes acceptLate: true. This stops a stale “joined” from Monday from answering Wednesday’s wait. See Guarantees.

Sending a signal only marks a waiting run as due; the run continues on the next tick(). Call tick() right after signal() if you want it to continue immediately.

Once

await f.once(key) returns true for the first run in the tenant that asks for that key and false for every other run, across all flows. The same run gets true again on replay. Use it to guard actions that must happen once per tenant regardless of which run reaches them first, such as “send the welcome pack once per customer”. Keys are up to 200 characters.

Log

await f.log(message) appends a line (up to 1 KB, redacted) to the run’s history. Lines are not repeated on replay.

Schedules

steady.schedule(flow, cron, { tz, input, key }) stores a cron schedule. Each tick first fires the schedules that are due: it starts a run with the key schedule:<key>:<firing time>, so two runners firing the same slot start one run. Cron expressions have five fields (minute, hour, day of month, month, day of week) with ranges, lists, steps, month and day names, and the macros @yearly, @monthly, @weekly, @daily, @midnight, @hourly. L, W, # and ? are not supported. The expression is read in the IANA time zone tz (default "UTC").

Missed firings collapse: after an outage, a schedule fires once and the next firing is computed from now. Re-registering a schedule with the same cron and zone on every boot keeps its next firing time, so a deploy never skips a due firing. steady.unschedule(key) removes it.

Tick and runners

steady.tick() does all the work, in this order:

  1. Release the leases of runs whose runner died (expired leases go back to pending).
  2. Fire due schedules.
  3. With concurrency workers (default 4), claim due runs one at a time and execute each until it completes, fails or parks. Each run executes at most once per tick.

A process that calls tick() is a runner. Any number of runners can tick against the same database at the same time: a claim takes a lease (FOR UPDATE SKIP LOCKED, then a lease owner and expiry on the row), so a run executes in one place. While a step runs, the runner extends its lease with a heartbeat every third of leaseMs. See Operations.

Tenancy

Every row carries a tenant. An instance serves one tenant (createSteady({ tenant }), default "default"), and every statement filters on it; asking for another tenant throws TenantAccessError. An administrative instance can serve every tenant with tenant: "*", allowCrossTenant: true; it must then name the tenant on every write.

History

steady.history(runId) returns the run, a time-ordered timeline (step attempts with timing, parks, log lines, signals including late ones), the raw step rows and the signals. Values in the timeline are summarized to 8 KB. The step log is append-only: Steady never updates or deletes a step row, and the optional sql/rls.sql script makes the database refuse it too.

Storage

Four tables, created by migrate() or sql/steady.sql:

Table Holds
steady_runs one row per run (and one per once key, with flow $once)
steady_steps the append-only step log: journal entries, retries, parks, log lines
steady_signals signals, consumed or not, with the late flag
steady_schedules cron schedules and their next firing time

Steady talks to Postgres through a one-method adapter (query(sql, params)) and sends one statement per operation; it never opens an interactive transaction. That is why the same code works on a pg pool, postgres.js and Neon’s HTTP driver.