durable-execution - v0.32.0
    Preparing search index...

    Type Alias TaskRunContext

    Runtime context provided to every task execution, containing metadata, signals and information about the execution environment.

    • Identity: taskId, executionId - Unique identifiers
    • Hierarchy: root, parent - Task relationship information
    • Signals: shutdownSignal, abortSignal - For graceful termination
    • Retry State: attempt, prevError - Retry attempt information
    const task = executor.task({
    id: 'processData',
    timeoutMs: 60000,
    run: async (ctx, input) => {
    console.log(`Execution ${ctx.executionId}, attempt ${ctx.attempt}`)

    // Check for executor shutdown or task cancellation
    if (ctx.shutdownSignal.aborted || ctx.abortSignal.aborted) {
    throw new DurableExecutionCancelledError()
    }

    // Check previous error if retrying
    if (ctx.prevError) {
    console.log('Retrying after:', ctx.prevError.message)
    }

    // Process data...
    return result
    }
    })
    type TaskRunContext = {
        root?: TaskExecutionSummary;
        parent?: ParentTaskExecutionSummary;
        taskId: string;
        executionId: string;
        shutdownSignal: AbortSignal;
        abortSignal: AbortSignal;
        attempt: number;
        prevError?: DurableExecutionErrorStorageValue;
    }
    Index

    Properties

    The root task execution.

    The parent task execution.

    taskId: string

    The task id.

    executionId: string

    The task execution id.

    shutdownSignal: AbortSignal

    The shutdown signal of the task. It is set when the executor is shutting down.

    abortSignal: AbortSignal

    The abort signal of the task. It is cancelled when the task gets cancelled or times out.

    attempt: number

    The attempt number of the task. The first attempt is 0, the second attempt is 1, etc.

    The error of the previous attempt.