feat(sdk): expose retry attempt number on step context#707
Merged
Conversation
ParidelPooya
force-pushed
the
feat/step-context-attempt
branch
2 times, most recently
from
July 9, 2026 23:13
58d4777 to
90167ca
Compare
Add a 1-based `attempt` field to `StepContext` so step functions can read the current retry attempt (1 on the first execution, incrementing by 1 on each retry). This enables attempt-aware logic such as failing over to an alternate resource on later attempts (issue #502). - Make `StepContext` an interface extending `OperationContext` with `attempt: number`; populate it in the step handler from the existing 1-based `currentAttempt` already used for `retryStrategy` and logging. - Keep 1-based numbering for consistency with the SDK logger (`DurableLogData.attempt`). - Update the `step()` TSDoc that described `StepContext` as logging-only and regenerate the API report entry accordingly. - Add unit tests covering the first-attempt and post-retry values. - Add a `step/attempt-fallback` example demonstrating supplier fail-over driven by `stepContext.attempt`. Closes #502
ParidelPooya
force-pushed
the
feat/step-context-attempt
branch
from
July 9, 2026 23:36
90167ca to
a18a585
Compare
yaythomas
approved these changes
Jul 10, 2026
ParidelPooya
marked this pull request as ready for review
July 10, 2026 17:43
ParidelPooya
added a commit
that referenced
this pull request
Jul 16, 2026
) Add `attempt` field to `WaitForConditionContext` so check functions can read the current retry attempt, mirroring the `StepContext.attempt` field added for step() in #707 (and matching the Java SDK, where waitForCondition's check function already reuses StepContext.getAttempt()). Previously only the wait strategy's positional `attempt` argument had this information; the check function itself had no way to know which attempt it was on without tracking state manually. - Convert WaitForConditionContext from a type alias to an interface extending OperationContext, adding attempt: number (1-based). - Populate it in the wait-for-condition handler from the existing currentAttempt already used for waitStrategy and logging. - Update the waitForCondition() and WaitForConditionCheckFunc TSDoc. - Add unit tests covering the first-attempt and post-retry values.
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.
Add
attemptfield toStepContextso step functions can read the current retry attempt. This enables attempt-aware logic such as failing over to an alternate resource on later attempts (issue #502).StepContextan interface extendingOperationContextwithattempt: number; populate it in the step handler from the existing 1-basedcurrentAttemptalready used forretryStrategyand logging.DurableLogData.attempt).step()TSDoc that describedStepContextas logging-only.step/attempt-fallbackexample demonstrating supplier fail-over driven bystepContext.attempt.Issue #, if available: #502
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.