Runlane
Understand Runlane

Workers, leases, and wakeups

See how workers claim tasks and how interrupted work becomes available again.

Workers turn queued runs into task attempts. Storage remains the source of truth throughout that process.

A lease gives one worker temporary ownership

Before it calls your code, a worker asks storage to claim the run. A successful claim creates a lease. Other workers lose the same claim and do not start that attempt under normal operation.

Long attempts refresh their lease. These heartbeats update current ownership without adding an event each time. If a worker loses ownership, it cannot later store a success as though it still owns the attempt.

A wakeup is only a hint

A storage-polling worker scans durable state for runnable work. A transport lane sends a message that tells a worker which run to check. In both cases, the worker re-reads storage before it executes anything.

This makes duplicate, late, and stale SQS messages safe inputs. They are not separate jobs and do not carry authoritative task state. If another path already moved the run forward, core ignores or resolves the old wakeup.

Interrupted work becomes available again

When a worker stops refreshing its lease, the lease eventually expires. Maintenance and runnable scans can then recover eligible work. If another valid lifecycle change wins first, that stored change wins the race.

Waiting on a token also releases the worker lease. Completing or timing out the token makes the linked runs eligible to resume. Runlane tries one small resume pass after completion, but maintenance keeps working through any links that remain.

Workers use bounded scans to move past candidates that are no longer runnable. Opaque cursors prevent an old rejected prefix from hiding later work.

Long-running workers pause between incomplete scan pages. A bounded drain() continues immediately, and only executed runs count toward maxRuns.

Shutdown is cooperative

Closing a worker aborts TaskContext.signal. That signal cannot forcibly stop JavaScript or undo an external effect. Pass it into I/O, and stop starting new work after cancellation or shutdown becomes durable.

Use run workers for process setup and run maintenance for recovery.

On this page