Repository navigation
GH-5068 DoThenRetry() error policy that works inline and from a queue - #5179
Merged
Merged
Conversation
…, inline or queued New OnException<T>().DoThenRetry(action, maxAttempts: 3) on IFailureActions/PolicyExpression (global policies and per-chain OnException). The continuation implements both IContinuation (action, then lifecycle.RetryExecutionNowAsync()) and IInlineContinuation (action, then InvokeResult.TryAgain). maxAttempts counts the original attempt like Requeue(maxAttempts), so it adds maxAttempts - 1 slots; when they run out the normal exhausted behaviour applies (dead letter when queued, exception thrown to the InvokeAsync() caller). RetryExecutionNowAsync() is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DCggXgxnG3EBXoR9rrq37U
Merged
This was referenced Oct 25, 2026
This was referenced Oct 29, 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.
What changed
DoThenRetry(action, maxAttempts = 3, description = "Do then retry")onIFailureActions/PolicyExpression, so it is available on global policies (opts.OnException<T>()), on a handler chain (chain.OnException<T>()), and afterThen.DoThenRetryContinuationSource/DoThenRetryContinuation. The continuation implements both:IContinuation: run the action, thenlifecycle.RetryExecutionNowAsync()(queued path, with the same retry tracing asRetryInlineContinuation)IInlineContinuation: run the action, then returnInvokeResult.TryAgain(IMessageBus.InvokeAsync()path)maxAttemptscounts the original attempt, likeRequeue(maxAttempts): it addsmaxAttempts - 1slots. Once they run out, the normal exhausted behaviour applies, the same asRetryTimes(): dead letter when queued, exception thrown to theInvokeAsync()caller.maxAttemptsmust be 2..25.RetryExecutionNowAsync()inline behaviour is unchanged.docs/guide/handlers/error-handling.md, sourced from the test'ssample_do_then_retryregion.Why
A
CustomActionthat does recovery work and then retries can't know whether it is running inline or queued, so the same lambda either throws (RetryExecutionNowAsync()inline) or doesn't retry. Users had to write their own dual continuation plus an attempts check.Tests run locally (net9.0, Release)
CoreTests --filter-class "*do_then_retry*": 6/6 passed (queued recover, inline recover, queued exhausted -> dead letter, inline exhausted -> throws, rule description/attempt slots withThen, argument validation)CoreTests --filter-namespace "CoreTests.ErrorHandling*": 249/249 passedsrc/WolverineandCoreTestsbuild with 0 warnings / 0 errorsCloses #5068
🤖 Generated with Claude Code
https://claude.ai/code/session_01DCggXgxnG3EBXoR9rrq37U