Skip to content

Latest commit

 

History

History
76 lines (43 loc) · 1.58 KB

File metadata and controls

76 lines (43 loc) · 1.58 KB

Home > @aws/durable-execution-sdk-js > DurableContext > step

DurableContext.step() method

Executes a function as a durable step with automatic retry and state persistence

Signature:

step<TOutput>(fn: StepFunc<TOutput, TLogger>, config?: StepConfig<TOutput>): DurablePromise<TOutput>;

Parameters

Parameter

Type

Description

fn

StepFunc<TOutput, TLogger>

Function to execute as a durable step

config

StepConfig<TOutput>

(Optional) Optional configuration for retry strategy, semantics, and serialization

Returns:

DurablePromise<TOutput>

Exceptions

{StepError} When the step function fails after all retry attempts are exhausted

Remarks

**IMPORTANT**: step() cannot group multiple durable operations. Use runInChildContext() to group steps, waits, or other durable operations together. See the named overload for details.

Example

const result = await context.step(async (ctx) => {
  return await fetchUserFromAPI(userId);
});