Skip to content

fix(scala): pass retry count to retryUntil delay function#6645

Merged
eric-zaharia merged 3 commits into
mainfrom
fix/scala-delay-mismatch
Jul 6, 2026
Merged

fix(scala): pass retry count to retryUntil delay function#6645
eric-zaharia merged 3 commits into
mainfrom
fix/scala-delay-mismatch

Conversation

@eric-zaharia

@eric-zaharia eric-zaharia commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

🧭 What and Why

🎟 JIRA Ticket: API-422

RetryUntil.retryUntil passed the current delay value back into the delay function instead of the retry count. Because the seed is delay(0) = 0 and the delay functions are multiplicative (e.g. retries * 200), the result collapsed to 0 and fed itself 0 on every subsequent retry — so no backoff ever happened and polling hammered the API with zero delay.

The parameter was already named retries and every caller treats it as a retry count, so this was purely a wiring bug: the input's intended meaning ("retry count") never matched what was passed in ("current delay").

Changes included:

  • Pass retryCount to delay(...) instead of the accumulated currentDelay.
  • Drop the now-unused currentDelay accumulator and the delay(0) seed from the internal attempt helper. attempt is a local nested function, so this is not a public API change — the retryUntil signature and DEFAULT_DELAY: Long => Long are unchanged, and no call sites needed edits.

Resulting backoff now ramps as intended:

Delay function Before After
DEFAULT_DELAY (retries * 200, cap 5000) 0, 0, 0, … 0, 200, 400, …, 5000ms
pollEvent (retries * 1500, cap 5000) 0, 0, 0, … 0, 1500, 3000, 5000ms

🧪 Test

  • yarn cli cts run scala passes. Note that CTS asserts polling correctness, not timing — the bug never broke correctness (it still polled, just with no delay), so CTS is a regression guard here rather than a direct validation of the backoff fix.

Found during review of #6312 (feat(scala): add withTransformation helpers).

@eric-zaharia eric-zaharia self-assigned this Jun 29, 2026
@algolia-api-clients-automation-bot

algolia-api-clients-automation-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

No code generated

If you believe code should've been generated, please, report the issue.

📊 Benchmark results

Benchmarks performed on the method using a mock server, the results might not reflect the real-world performance.

Language Req/s
scala 23

@eric-zaharia eric-zaharia marked this pull request as ready for review June 29, 2026 11:14
@eric-zaharia eric-zaharia requested a review from a team as a code owner June 29, 2026 11:14
@eric-zaharia eric-zaharia enabled auto-merge (squash) July 6, 2026 10:42
@eric-zaharia eric-zaharia merged commit 90bb3e0 into main Jul 6, 2026
12 checks passed
@eric-zaharia eric-zaharia deleted the fix/scala-delay-mismatch branch July 6, 2026 12:35
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.

2 participants