Skip to Content
Runlane
Understand Runlane

How durable execution works

See what Runlane saves, what restarts, and what your task must make safe.

A normal function call disappears with its process. Runlane first stores the request to do the work, then lets a worker execute it. If the worker stops, the stored run is still there.

A run is not an attempt

The run is the durable record of the work. It contains the validated payload, current status, timing, output, failure, and event history.

An attempt is one worker trying to execute that run. A retry, release, deploy, or recovered worker can start another attempt. Each new attempt calls the task handler from the beginning.

This separation lets Runlane keep the work even when a process disappears.

What survives a restart

With a durable lane, Runlane stores:

  • the run and its event history;
  • retry and wait state;
  • worker ownership and deadlines;
  • completed durable step results;
  • schedule occurrences and pending delivery work.

The local lane uses the same model in dev's memory. Apps reach that store over the loopback bridge; without dev, storage operations fail. Dev's data disappears when dev exits. createTestLane() uses separate process memory for tests. Production lanes store state in Postgres.

What durability does not guarantee

Durable execution does not make arbitrary code run exactly once. An external API call can succeed just before the worker stops, leaving Runlane without a stored success. Recovery may run that code again.

Make repeated execution safe. Use the external provider's idempotency feature, or wrap the call in a durable step and give the provider a stable idempotency token. See make side effects safe to repeat for patterns.

Ordinary local variables do not survive an attempt. A later attempt starts the handler from the beginning and reuses only state that was stored outside the process.

Maintenance keeps durable work moving

Storage preserves state. Maintenance moves deferred and interrupted work forward. It creates runs for due schedules, wakes due retries and waits, recovers expired ownership, finalizes abandoned work, and publishes deferred wakeups.

A durable database can preserve a stuck run perfectly. Before production, give maintenance a clear owner.

Start with the local quickstart, then choose a durable lane.

Code changes need a saved decision

A run keeps the code version from its first start. Later workers can have different code. Use context.patched() to save a boolean before choosing between an old and new replay path. An unmarked run on a different version takes the old path because code identity alone cannot show which commands it already ran. Saved decisions remain stable across later attempts. Follow deploy task changes when changing replay paths or schemas.

Check a handler's replay behavior

assertReplaySafe from @runlane/core/testing runs a callback-step handler twice against the same Local run and saved checkpoints. It uses a controlled clock and inserts a durable sleep after the first successful return. The factory overload can wrap test effects and detect calls outside saved step callbacks or repeated on replay, even when the handler catches the violation.

It detects only wrapped effects. Unwrapped filesystem, database, and SDK calls, randomness, and clocks remain undetected. A pass is not proof of arbitrary side-effect safety. It also does not simulate a crash between an external effect and its checkpoint. Keep provider idempotency and full runtime tests for those boundaries.

Task-owned suspensions, child workflows, cancellation, and more than two handler entries are unsupported. Install @runlane/local-adapters and @runlane/testing as development dependencies to use the assertion. The production core entry does not load these optional peers.

On this page