remora-monorepo / lib / DurableContext
Interface: DurableContext
Defined in: packages/core/src/executor/context.ts:23
Injectable execution context for durable execution environments.
In a durable environment (AWS Step Functions, Temporal, Inngest, etc.), each step() runs in its own execution environment. The workflow code outside of step() closures re-executes on every resume, so it must be idempotent (pure reads, expression evaluation, scope construction). Code inside a step() closure runs exactly once — the environment records its result and replays the cached value on subsequent resumes instead of re-executing the function.
Properties
sleep()
sleep: (
name,durationMs) =>Promise<void>
Defined in: packages/core/src/executor/context.ts:39
Sleep for the given duration. In durable environments, this uses a durable timer that survives process restarts. Default: setTimeout-based promise.
Parameters
name
string
durationMs
number
Returns
Promise<void>
step()
step: (
name,fn) =>Promise<unknown>
Defined in: packages/core/src/executor/context.ts:32
Wrap a step that should execute exactly once. In durable environments, fn runs on the first invocation and its result is persisted; on subsequent resumes the cached result is returned without calling fn again. All code outside step() must be idempotent because it re-runs on every resume. Default: executes the function directly (passthrough).
Parameters
name
string
fn
() => Promise<unknown>
Returns
Promise<unknown>
waitForCallback()?
optionalwaitForCallback: (name,submitter,timeoutMs?) =>Promise<unknown>
Defined in: packages/core/src/executor/context.ts:66
Wait for an external callback. Creates a callback ID, calls the submitter function with it, then parks the workflow until the external system submits a result via that callback ID.
In durable environments (AWS Lambda Durable, Temporal, etc.), the function terminates with zero compute cost while waiting. When the callback arrives, the environment re-invokes the function and replays to this point.
Default: not available. When absent, the executor falls back to polling via conditionFn. When present, both waitForCallback and polling run concurrently — whichever resolves first wins.
Parameters
name
string
submitter
(callbackId) => Promise<void>
timeoutMs?
number
Returns
Promise<unknown>
waitForCondition()
waitForCondition: (
name,checkFn,options) =>Promise<unknown>
Defined in: packages/core/src/executor/context.ts:46
Wait for a condition by polling. In durable environments, this might use waitForCallback or durable polling. Default: loop with setTimeout + backoff.
Parameters
name
string
checkFn
() => Promise<unknown>
options
Returns
Promise<unknown>