-
Notifications
You must be signed in to change notification settings - Fork 22
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected behavior in ExponentialStrategy #18
Comments
If this behavior is unintended, I can prepare a pull request with a fix promptly. However, it's worth noting that such a change would be a breaking change. |
Thank you for this! Definitely looks like a bug. I wrote that Yes I would welcome a PR. And I'm not sure I would consider it breaking, it seems like a bugfix to me, making this behave the way it should have all along. And there is no impact to users of this library in terms of how they implement it, no API changes. |
@jszobody I've put together a PR for this. Would really appreciate if you could take a look when you have a moment: Thanks in advance! |
The current implementation of
ExponentialStrategy
in the Backoff library produces an unexpected sequence of wait times. Instead of the conventional exponential backoff sequence (1, 2, 4, 8, ...), it generates a sequence of (1, 4, 8, 16, ...).Current Behavior
Given a base wait time of 1 second (1000 ms), the current implementation results in:
Expected Behavior
The expected exponential backoff sequence should be:
Code Analysis
The issue stems from the current implementation in
ExponentialStrategy
:This implementation causes the exponential growth to start from the second attempt, resulting in the unexpected sequence.
Proposed Fix
To achieve the expected behavior, the
getWaitTime
method could be modified as follows:This change would produce the conventional exponential backoff sequence.
The text was updated successfully, but these errors were encountered: