durable-execution-sdk-js.md

December 2, 2025 ยท View on GitHub

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

durable-execution-sdk-js package

Classes

Class

Description

CallbackError

Error thrown when a callback operation fails

ChildContextError

Error thrown when a child context operation fails

DurableExecutionApiClient

Durable execution client which uses an API-based LambdaClient with built-in error logging. By default, the Lambda client will have custom timeouts set.

DurablePromise

A promise that defers execution until it's awaited or .then/.catch/.finally is called

InvokeError

Error thrown when an invoke operation fails

StepError

Error thrown when a step operation fails

StepInterruptedError

Error thrown when a step with AT_MOST_ONCE_PER_RETRY semantics was started but interrupted before completion.

WaitForConditionError

Error thrown when a wait for condition operation fails

Abstract Classes

Abstract Class

Description

DurableOperationError

Base class for all durable operation errors

Enumerations

Enumeration

Description

BatchItemStatus

The status of a batch item

InvocationStatus

Status enumeration for durable execution invocation results.

This enum defines the possible outcomes of a durable execution invocation, indicating whether the execution completed successfully, failed, or is continuing asynchronously.

The status determines how the AWS durable execution service will handle the execution: - SUCCEEDED: Execution completed successfully with a final result - FAILED: Execution failed with an error that cannot be retried - PENDING: Execution is continuing and will be resumed later (checkpointed)

JitterStrategy

Jitter strategy for retry delays to prevent thundering herd. Jitter reduces simultaneous retry attempts by spreading retries out over a randomized delay interval.

OperationSubType

Operation subtype enumeration for categorizing different types of durable operations.

This enum provides fine-grained classification of durable operations beyond the basic operation types. Subtypes enable improved observability for specific operation patterns.

Each subtype corresponds to a specific durable context method or execution pattern.

StepSemantics

Functions

Function

Description

createClassSerdes(cls)

(BETA) Creates a Serdes for a specific class that preserves the class type. This implementation is a basic class wrapper and does not support any complex class structures. If you need custom serialization, it is recommended to create your own custom serdes.

createClassSerdesWithDates(cls, dateProps)

(BETA) Creates a custom Serdes for a class with special handling for Date properties. This implementation is a basic class wrapper and does not support any complex class structures. If you need custom serialization, it is recommended to create your own custom serdes.

createRetryStrategy(config)

Creates a retry strategy function with exponential backoff and configurable jitter

createWaitStrategy(config)

withDurableExecution(handler, config)

Wraps a durable handler function to create a handler with automatic state persistence, retry logic, and workflow orchestration capabilities.

This function transforms your durable handler into a function that integrates with the AWS Durable Execution service. The wrapped handler automatically manages execution state and checkpointing.

Interfaces

Interface

Description

BatchItem

Represents a single item in a batch result

BatchResult

Result of a batch operation (map, parallel, or concurrent execution)

ChildConfig

Configuration options for child context operations

CompletionConfig

ConcurrencyConfig

Configuration options for concurrent execution operations

ConcurrentExecutionItem

Represents an item to be executed with metadata for deterministic replay

DurableContext

DurableExecutionClient

Client interface for durable execution backend operations.

This interface defines the core operations needed to manage durable execution state and checkpoints. It abstracts the underlying service calls and provides a clean contract for: - Retrieving execution state during replay scenarios - Creating checkpoints for state persistence - Managing long-running workflow state

Implementations of this interface handle the communication with AWS services to ensure durable execution capabilities including automatic retry, state recovery, and workflow orchestration.

DurableExecutionConfig

Configuration options for durable execution setup.

This interface allows customization of the durable execution runtime behavior, primarily for dependency injection and testing scenarios. In most production use cases, the default configuration is sufficient.

DurableExecutionInvocationInput

Input structure for durable execution invocations.

This interface defines the payload structure that the durable execution service provides to durable functions. It contains all the necessary information for the Durable Execution Language SDK to: - Manage checkpointing and state persistence - Replay completed operations from previous state

The input is automatically provided by the durable execution service and contains both execution metadata and the operation history for replay.

DurableLogData

Log data passed to the durable logger when getDurableLogData is called.

DurableLogger

This interface provides structured logging capabilities for durable execution contexts. A custom logger must implement this interface to be used by the Durable Execution Language SDK. The SDK will automatically parse the logger and use the appropriate logging method based on the log level.

DurableLoggingContext

The durable logging context that can be used to provide durable execution metadata such as executionArn, operationId, and attempt.

InvokeConfig

Configuration options for invoke operations

MapConfig

Configuration options for map operations

RetryDecision

Decision returned by a retry strategy function

RetryStrategyConfig

Configuration options for creating a retry strategy

Serdes

Serdes (Serialization/Deserialization) interface for durable functions. This interface allows customizing how data is serialized and deserialized when persisting state in durable functions.

Both methods are async to support custom implementations that need to interact with external services (e.g., AWS S3, DynamoDB, etc.)

StepConfig

Configuration options for step operations

WaitForConditionConfig

Configuration options for waitForCondition operations

WaitStrategyConfig

Variables

Variable

Description

defaultSerdes

Default Serdes implementation using JSON.stringify and JSON.parse Wrapped in Promise.resolve() to maintain async interface compatibility Ignores context parameter since it uses inline JSON serialization

Note: Uses 'any' type intentionally as this is a generic serializer that must handle arbitrary JavaScript values. JSON.stringify/parse work with any type, and using more restrictive types would break compatibility with the generic Serdes interface when T can be any type.

retryPresets

Pre-configured retry strategies for common use cases

Type Aliases

Type Alias

Description

ConcurrentExecutor

Executor function type for concurrent execution

DurableContextLogger

The durable logger available inside a context.

DurableExecutionHandler

A handler function type for a durable execution that provides automatic state persistence, retry logic, and workflow orchestration capabilities.

This handler type is the core interface for building stateful, long-running AWS Durable Executions using the Durable Execution SDK. The handler receives a durable context that enables: - Step-based execution with automatic checkpointing and replay - Built-in retry strategies with exponential backoff and jitter - Workflow orchestration with parallel execution and child contexts - External system integration via callbacks and conditional waiting - Batch operations with concurrency control

This handler function must be wrapped by withDurableExecution() to enable durable execution capabilities. During replay scenarios, the handler function is re-executed, however the durable context operations that already completed(steps, waits, callbacks, etc.) are not re-executed.

DurableExecutionInvocationOutput

Union type representing all possible output formats for durable execution invocations.

This type defines the complete response structure that durable functions return to the AWS Durable Execution service. The response format varies based on the execution outcome:

**Successful Completion (SUCCEEDED):** - Contains the final execution result (if any) as a serialized string - Indicates the execution has completed and no further invocations are needed - The Result field may be undefined for void functions or large results that were checkpointed

**Execution Failure (FAILED):** - Contains structured error information including message and stack trace - Indicates an unrecoverable error that terminates the execution - No further automatic retries will occur

**Continued Execution (PENDING):** - Indicates the execution is continuing asynchronously - Common for operations involving waits, callbacks, or retries - The execution will be resumed in a future invocation

The durable execution service uses this response to determine next steps: - Schedule continuation for PENDING status - Complete the execution for SUCCEEDED status - Complete the execution for FAILED status

DurableLambdaHandler

The handler type returned by withDurableExecution() that handles durable execution behaviour.

This handler type represents the final lambda function that gets deployed and invoked by the Durable Execution service.

The handler receives DurableExecutionInvocationInput containing execution metadata, checkpoint tokens, and operation history, then returns DurableExecutionInvocationOutput with execution status and results.

Duration

Type representing time durations for durable execution operations, such as wait, retry, and timeout options.

**Supported Units:** - days: Number of days - hours: Number of hours - minutes: Number of minutes - seconds: Number of seconds

**Usage Rules:** - At least one time unit must be specified - All numeric values must be positive integers - Fractional values are not supported

MapFunc

Function to be executed for each item in a map operation

StepFunc

Function to be executed as a durable step

WaitForConditionCheckFunc

Function that checks and updates state for waitForCondition operations

WaitForConditionDecision

Decision object for waitForCondition wait strategy

WaitForConditionWaitStrategyFunc

Function that determines whether to continue waiting and how long to delay