Home > @aws/durable-execution-sdk-js > DurableContext > step
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>;|
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>
{StepError} When the step function fails after all retry attempts are exhausted
**IMPORTANT**: step() cannot group multiple durable operations. Use runInChildContext() to group steps, waits, or other durable operations together. See the named overload for details.
const result = await context.step(async (ctx) => {
return await fetchUserFromAPI(userId);
});