Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork21
fix: correct current_try increment during step retries#257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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
barnabasJ approved these changesAug 7, 2025
Comment on lines 68 to 73
| # Current behavior (current_try does not immediately increment). | ||
| # Uncomment to make the test pass: | ||
| # {:run_start, _, 0}, | ||
| # {:run_error, %RunStepError{error: :fail}, 0}, | ||
| # {:compensate_start, %RunStepError{error: :fail}, 0}, | ||
| # :compensate_retry, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Suggested change
| # Current behavior (current_try does not immediately increment). | |
| # Uncomment to make the test pass: | |
| # {:run_start, _, 0}, | |
| # {:run_error, %RunStepError{error: :fail}, 0}, | |
| # {:compensate_start, %RunStepError{error: :fail}, 0}, | |
| # :compensate_retry, |
Fix bug where current_try was not properly incremented during step retriesdue to incorrect default value in increment_retries function.The issue was in Map.update/4 usage:- Map.update(retries, step_ref, 0, &(&1 + 1)) set retry count to 0 for first retry- Should be Map.update(retries, step_ref, 1, &(&1 + 1)) to set retry count to 1Also updated retry limit check from >= to > for correct max_retries semantics:- max_retries 1 should allow 1 retry (2 total attempts)- Previous check retry_count >= max_retries prevented thisChanges:- lib/reactor/executor/async.ex: Fix increment_retries default and limit check- lib/reactor/executor/sync.ex: Fix increment_retries default and limit check- test/reactor/executor/async_test.exs: Update test expectation- test/reactor/executor/compensation_test.exs: Add test case from@skandermFixes current_try progression: 0 → 1 → 2 instead of 0 → 0 → 1
478c80d to32c4827Compared2a2ee1 intomain 22 checks passed
Uh oh!
There was an error while loading.Please reload this page.
Sign up for freeto 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.
Uh oh!
There was an error while loading.Please reload this page.
Contributor checklist
Leave anything that you believe does not apply unchecked.
Summary
Fix bug where `current_try` was not properly incremented during step retries, causing incorrect attempt numbering in retry scenarios.
Problem
The `current_try` context value was not being incremented correctly during step retries:
This was caused by a bug in the `increment_retries` function using an incorrect default value in `Map.update/4`.
Root Cause
The issue was in both `lib/reactor/executor/async.ex` and `lib/reactor/executor/sync.ex`:
```elixir
Incorrect - sets retry count to 0 for first retry
Map.update(state.retries, step.ref, 0, &(&1 + 1))
Correct - sets retry count to 1 for first retry
Map.update(state.retries, step.ref, 1, &(&1 + 1))
```
Additionally, the retry limit check used `>=` instead of `>`, which prevented the correct number of retries when `max_retries` was set.
Solution
Changes
Test Results
✅ All existing tests pass
✅ New test case passes with correct `current_try` progression
✅ No regressions in retry behavior
✅ `mix check` passes all quality checks
The fix ensures `current_try` correctly progresses: 0 → 1 → 2 instead of the previous incorrect 0 → 0 → 1 progression.
Includes the reproduction test from#243