Skip to main content

Interface: StepRunContext

Defined in: packages/workflow-engine/src/core/steps.ts:105

What a ctx.step.run body is told about its own execution.

Bodies that ignore it behave exactly as before; it exists so a body making a non-idempotent external call can name that call in a way that survives a replay.

Properties​

abortSignal​

readonly abortSignal: AbortSignal

Defined in: packages/workflow-engine/src/core/steps.ts:141

The same signal as ctx.abortSignal: aborted when the run is cancelled while this body executes, or when the job lease this worker holds is lost. Pass it to fetch, the AI helper, or anything else that can be interrupted. abortSignal.reason is a StageAbortedError.


attempt​

readonly attempt: number

Defined in: packages/workflow-engine/src/core/steps.ts:118

1 on the first execution; incremented each time the step is taken over.


externalKey​

readonly externalKey: string

Defined in: packages/workflow-engine/src/core/steps.ts:116

A stable, deterministic key for whatever external effect this body creates. Identical on every replay of this step, so it can be sent as a provider idempotency key, stamped into provider-side metadata, or used to search for an effect a dead worker already created.

Recorded on the step row before the body runs, never after it returns.


isReclaim​

readonly isReclaim: boolean

Defined in: packages/workflow-engine/src/core/steps.ts:124

True when this execution took over an expired lease or a failed attempt, i.e. when an earlier execution of this body may already have run. A body that can recover its external effect should look for it when this is set.


stepId​

readonly stepId: string

Defined in: packages/workflow-engine/src/core/steps.ts:107

This step's id, as passed to run.

Methods​

heartbeat()​

heartbeat(): Promise<void>

Defined in: packages/workflow-engine/src/core/steps.ts:134

Extend this execution's lease by the step's lease from now. Call it from a body that legitimately outlives its lease (between pages of a long export, say) so a replay does not take the step over mid-flight. Rejects with StepLeaseLostError when the row is no longer this execution's — the lease already expired and another worker took the step over — in which case the body's outcome will not be recorded either, and it should stop.

Returns​

Promise<void>