Skip to content

Fix AdaptiveRetry stopping on Left when shouldPayFailureCost returns false#448

Closed
adamw wants to merge 1 commit into
masterfrom
fix-adaptive-retry-stops-on-left-when-not-paying
Closed

Fix AdaptiveRetry stopping on Left when shouldPayFailureCost returns false#448
adamw wants to merge 1 commit into
masterfrom
fix-adaptive-retry-stops-on-left-when-not-paying

Conversation

@adamw
Copy link
Copy Markdown
Member

@adamw adamw commented May 29, 2026

Fixes #442.

When AdaptiveRetry encounters a Left error and shouldPayFailureCost returns false, retrying should continue. Currently, the retry stops in this scenario.

This commit adds a failing test that demonstrates the expected behavior: retries should continue for the configured schedule even when the cost is not paid (shouldPayFailureCost returns false).

Closes #442.

@adamw
Copy link
Copy Markdown
Member Author

adamw commented May 29, 2026

The failure is clear. Here's the summary:


CI failure: ImmediateRetryTest — one test, both Java 21 and 24

- should not pay exceptionCost if Left error is going to be retried
  and shouldPayPenaltyCost returns false *** FAILED ***
  1 was not equal to 6 (ImmediateRetryTest.scala:228)

The test asserts that when shouldPayPenaltyCost returns false and the result is a Left that will be retried, the penalty cost counter stays at 6 (untouched across retries). Instead it is 1, meaning the implementation is charging the penalty cost on the first attempt and stopping, rather than skipping the cost and continuing to retry. This is the intentional failing test added to document the bug this PR is meant to fix.

@adamw adamw closed this May 29, 2026
@adamw adamw deleted the fix-adaptive-retry-stops-on-left-when-not-paying branch May 29, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ox AdaptiveRetry stops retrying on Left when shouldPayFailureCost is false

1 participant