Support retry handling when calling activity/suborchestrations#77
Merged
YunchuWang merged 5 commits intomainfrom Jan 31, 2026
Merged
Support retry handling when calling activity/suborchestrations#77YunchuWang merged 5 commits intomainfrom
YunchuWang merged 5 commits intomainfrom
Conversation
delete old task when scheduling retries
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces configurable retry policies for activities and sub-orchestrations in the Durable Task JS SDK, and wires them through the orchestration context and executor. It also adds unit and end-to-end tests to validate retry behavior (including exponential backoff and exhaustion of attempts) and ensures basic backward compatibility for callActivity without retry options.
Changes:
- Add
RetryPolicy/RetryPolicyOptions,RetryableTask, andRetryTimerTasktypes plus simpleTaskOptions/SubOrchestrationOptionshelpers to model retryable orchestrator work and timers. - Extend
OrchestrationContextandRuntimeOrchestrationContextto accept options oncallActivity/callSubOrchestrator, create retryable tasks and retry timers, and reschedule work when retry timers fire. - Update the orchestration executor to interpret
RetryTimerTasks on timer-fired events, drive retry attempts for activities and sub-orchestrations, and add comprehensive unit and E2E tests to validate the retry pipeline end-to-end.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
test/e2e-azuremanaged/orchestration.spec.ts |
Adds E2E coverage verifying activity and sub-orchestration retry behavior, exponential backoff, retry exhaustion, and backward compatibility when no retry policy is provided. |
packages/durabletask-js/test/retryable-task.spec.ts |
Adds unit tests for RetryableTask covering initial state, exponential backoff, max interval capping, timeout handling, attempt counting, failure recording, and task-type handling. |
packages/durabletask-js/test/retry-policy.spec.ts |
Adds unit tests for RetryPolicy construction, defaults, and validation of invalid option combinations. |
packages/durabletask-js/test/orchestration_executor.spec.ts |
Adds executor-level tests that simulate history to verify scheduling of retry timers, rescheduling of activities after timer fire, and orchestration completion/failure after retries. |
packages/durabletask-js/src/worker/runtime-orchestration-context.ts |
Wires TaskOptions/SubOrchestrationOptions into callActivity/callSubOrchestrator, instantiates RetryableTasks, and introduces createRetryTimer/rescheduleRetryableTask to support retry scheduling. |
packages/durabletask-js/src/worker/orchestration-executor.ts |
Integrates retry handling into the executor by recognizing RetryTimerTasks on timer-fired events and driving RetryableTask retry cycles on task-failed/sub-orchestration-failed events. |
packages/durabletask-js/src/task/retryable-task.ts |
Implements RetryableTask, which tracks attempts, stores last failure details, computes next retry delay using a RetryPolicy, and customizes failure behavior. |
packages/durabletask-js/src/task/retry/retry-policy.ts |
Introduces the RetryPolicy class and RetryPolicyOptions interface, with validation and defaults for attempts, backoff, max interval, and retry timeout. |
packages/durabletask-js/src/task/retry/index.ts |
Exports RetryPolicy and RetryPolicyOptions from the retry module for internal and public consumption. |
packages/durabletask-js/src/task/retry-timer-task.ts |
Adds RetryTimerTask, a CompletableTask wrapper that links a timer to its parent RetryableTask for rescheduling. |
packages/durabletask-js/src/task/options/task-options.ts |
Defines TaskOptions and SubOrchestrationOptions (including retry and instance ID) and helper creators to derive them from a RetryPolicy. |
packages/durabletask-js/src/task/options/index.ts |
Re-exports task option types and helper functions as part of the task options module. |
packages/durabletask-js/src/task/context/orchestration-context.ts |
Updates the abstract OrchestrationContext API and documentation for callActivity/callSubOrchestrator to accept the new options types. |
packages/durabletask-js/src/index.ts |
Exposes RetryPolicy, RetryPolicyOptions, and the task option types/helpers from the package root so SDK consumers can configure retries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
kaibocai
approved these changes
Jan 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds support for configurable retry policies for activities and sub-orchestrations in the Durable Task JS SDK. It introduces new types and options for specifying retry behavior, implements the core retry logic, and refactors orchestration context methods to accept these new options. The changes are organized into three main themes: retry policy implementation, orchestration context API updates, and integration with the orchestration executor.
Retry policy implementation:
RetryPolicyclass andRetryPolicyOptionsinterface inretry-policy.ts, allowing users to specify max attempts, backoff, max interval, and timeout for retries. Includes validation and documentation.RetryableTaskclass to track retry attempts, failures, and compute the next retry delay using exponential backoff.RetryTimerTaskclass to represent timer tasks associated with retryable tasks, enabling precise retry scheduling.Orchestration context API updates:
OrchestrationContextmethods (callActivityandcallSubOrchestrator) to accept newTaskOptionsandSubOrchestrationOptionsparameters, allowing users to configure retry policies and instance IDs for sub-orchestrations.taskOptionsFromRetryPolicy,subOrchestrationOptionsFromRetryPolicy) and option types intask-options.tsfor easier creation of options from retry policies.Integration with orchestration executor:
RetryTimerTaskinstances, rescheduling the original retryable task when a retry timer fires.These changes enable robust, configurable retries for activities and sub-orchestrations, improving reliability and developer control over task execution in orchestrations.