Fix: Check Attempts For Error even when Attempts is zero #131
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 MR fixes a logic issue where AttemptsForError was ignored when the global Attempts value was set to 0. Since version 4.3.0, the retry library introduced AttemptsForError to allow fine-grained retry limits per error type. However, this mechanism was silently bypassed if retry.Attempts(0) was set, causing unexpected behavior and making debugging difficult.
Additionally, the logic for calling Is Recoverable was moved into the main retry loop to ensure it is properly respected for all configured attempts and error types.
Changes:
Apply AttemptsForError even if retry.Attempts(0) is used
Move IsRecoverable logic into the core retry loop to ensure it is evaluated consistently
Backward Compatibility:
This change makes retry behavior more consistent and does not break existing configurations unless users relied on the undocumented behavior of Attempts(0) disabling all retry logic.