Skip to the content.

Guarantees

This page states what Steady promises, what it does not, and why. The rules here are exercised by the tests in src/, against the memory store and, with STEADY_TEST_DATABASE_URL set, a real Postgres.

Steps: exactly-once results, at-least-once bodies

“Exactly once” in Steady means: each step position of a run gets exactly one recorded result, and once it is recorded, the flow always sees that result. It does not mean the body runs once.

A step goes through three moments: the body starts, the body finishes, the result is recorded. The record is a single atomic statement that appends the journal row and advances the run’s cursor together, and only the current lease holder can make it.

The process dies… On resume
before the body starts the body runs (first time)
while the body runs the body runs again
after the body finished, before the result was recorded the body runs again
after the result was recorded the recorded result is returned; the body does not run

So a step body is executed at least once, and more than once only when the process dies (or loses its lease) during that step. Every such run of the body is an attempt of the step’s retry policy (see Retries), so a step whose body keeps crashing the runner stops after maxAttempts instead of running forever. Write bodies to be idempotent:

The journal never has two completed rows for one position, even when two runners race: the record is conditional on the lease owner and on the expected cursor.

Determinism between steps

On every resume the flow function runs again from the top and replays the journal. Code outside f.* calls therefore runs many times. It must make the same f.* calls in the same order given the same input and recorded results.

Safe between steps: computing on the input and on step results, if/for over them, building strings. Not safe between steps: Date.now(), Math.random(), crypto.randomUUID(), reading a database or an API, reading environment variables that may change. Put those inside a step and use its recorded result.

If the code changes so that a recorded position no longer matches, the run fails with ReplayMismatchError (for example the journal recorded "render" but the flow called "send"). The same happens when the flow returns before replaying every recorded position. Steady never reuses a result for a different step. A renamed step is a new step: deploy renames only when no run is in flight past that point, or keep the old name.

Retries

A step that throws is retried by its policy (default: 3 attempts in total, 1 s backoff doubling up to 5 minutes, no jitter). Between attempts the run is parked as pending with a wake time, so the next attempt happens on the first tick at or after now + backoff. With a one-minute tick, any backoff under a minute effectively means “next tick”.

Every attempt counts, including the ones that never report back. Before a step body runs, Steady records the attempt number on the run (attempts) in a fenced write. If the body never finishes (the process died, for example at a serverless maxDuration, or the lease was lost), or its result cannot be recorded, the next runner that resumes the run sees that the attempt was used. When the attempt that never reported back was the last one allowed, the body does not run again: the step fails with “Attempt N of step … did not finish” like any exhausted step.

An attempt can also be used up without the body running at all: if the write that records the attempt commits but its response is lost (a dropped connection, a timeout), the runner cannot tell that it committed and stops before the body, and the next runner sees the attempt as used. With maxAttempts: 1 such a step then fails with “did not finish” although its body never ran. Keep maxAttempts at 2 or more for steps with side effects (the default is 3); the step is then at most N attempts, and a lost response costs one of them, not the step.

When attempts are exhausted, or nonRetryable(error) returns true, a failed journal entry is recorded and StepFailedError is thrown into the flow. If the flow catches it, the flow continues, and the failure replays identically on later resumes. If not, the run ends failed with the error text (a dead letter). retryNow(runId) re-opens a failed run at the failed step with fresh attempts; earlier steps are not run again.

A result that is not JSON-serializable, larger than 64 KB, or that contains a NUL character (\u0000, which Postgres jsonb cannot store) fails the step immediately without retry (retrying would produce the same result). NUL characters are removed from stored error texts and log lines. A write the database refuses as data (SQLSTATE class 22, data exception) fails the run instead of being treated as an outage, since the same write would be refused again. A stored value that cannot be decrypted (DecryptionError) affects only its run: by default (onDecryptionError: "retry") the run is released for 5 minutes with its attempts untouched and fails after 24 hours of failed decryption; with "fail" it fails at once.

Leases and concurrency

Idempotent start

start(flow, input, { key }) inserts with ON CONFLICT DO NOTHING on a unique index over (tenant, flow, key) and returns the existing run when there is one, untouched, with created: false. Fifty concurrent starts with the same key create one run. Without a key, every call creates a new run.

Signals and timeouts

Example: an intro meeting waits for joined with a 20-minute timeout, gets null, marks a no-show, sleeps two days and waits for joined again. A joined that arrived 25 minutes after the first invite is late; it does not answer the second wait. A joined sent during the second wait does.

Sleep

A sleep records its wake time once. On replay, the recorded wake time is used, so a sleep is never extended by a resume. The run continues on the first tick at or after the wake time.

Schedules, outages and DST

Cancellation

cancel(runId) flips a pending, sleeping, waiting or running run to cancelled at once. A runner that is executing it is refused at its next write and reports cancelled. A step body that was in flight may already have had its side effect; its result is discarded. Cancelled runs are never resumed.

Payloads and caps

Sizes are UTF-8 bytes of the JSON text. Oversize data is rejected with PayloadTooLargeError; nothing is stored and nothing is silently truncated. Inputs, signal payloads and schedule inputs with a NUL character are refused with ValidationError.

What Limit
Run input, schedule input 64 KB
Step result, flow output 64 KB
Signal payload 16 KB
Log line 1 KB
Stored error text 1 KB (cut with a ...[truncated N bytes] marker; never a stack trace)
Operations (steps, sleeps, waits, once) per run 10,000 (the next one fails the run)
Log lines per run 10,000 (the next one fails the run, even if the flow catches errors)
Unconsumed signals per run 1,000 (the next signal() is refused)

history() and onEvent summarize values over 8 KB as { $truncated: true, bytes, preview }. Stored values are never changed by summarizing.

What Steady does not guarantee