Skip to content

Retry as many times as retries says - #23

Merged
PetrHeinz merged 5 commits into
mainfrom
claude/retry-count
Sep 30, 2026
Merged

PetrHeinz merged 5 commits into
mainfrom
claude/retry-count

Conversation

@PetrHeinz

@PetrHeinz PetrHeinz commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

#25 is stacked on this PR, so the order is #20, this PR, then #25.

retries counts attempts, not retries: Client.Send runs for (i = 0; i < retries; ++i), so the default retries="10" makes ten attempts, and retries="0" never sends anything and drops every batch without a word. The doc comment of the property and the example README call it the number of retries.

  • The first attempt always happens, then up to retries retries with the same back-off as before: 1 second before the first retry, 2 before the second, and so on.
  • The default stays 10, which is now 11 attempts: a batch that keeps failing is given up on after 55 seconds of back-off instead of 45.
  • The "dropped N logs after M failed attempts" error from Log failed responses and do not retry rejected batches #20 reports the real number of attempts.
  • retries="0" sends every batch once and never retries it.
  • The doc comment of Retries and the example README say that it counts retries after the first attempt. The public Client constructor's retries parameter changes its meaning the same way.

KeepsDeliveringAfterBatchRanOutOfRetries and LogsTheBatchDroppedAfterRetries pinned the old count (Retries = 1 was a single attempt): they now answer two 500s, expect both attempts, and the error line says 2 failed attempts. Two new tests pin the count: Retries = 0 gets exactly one request, Retries = 2 gets exactly three with the same body, and in both the next log is still delivered.

The first commit adds the tests and is expected to be red: with Retries = 0 nothing is sent at all, and the other three wait in vain for the last attempt. The second commit changes the loop.

🤖 Generated with Claude Code

PetrHeinz and others added 4 commits September 30, 2026 16:06
…are not logged

A 401 is retried like a server error, and neither the status of a failed response nor a dropped batch shows up in NLog's internal log. The 408 and 429 cases pass already and pin that those stay retried.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every non-success response now writes its status and reason phrase to NLog's internal log. Only responses worth another attempt are retried: no response, 408, 429 and 5xx. Any other status drops the batch right away with an error, which for 401 and 403 hints at the source token and the endpoint. A batch that runs out of retries is no longer dropped silently either.

Based on the status code handling in #7.

Co-authored-by: Rolf Kristensen <11509660+snakefoot@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
retries="0" sends nothing at all and retries="1" makes a single attempt.
The two tests that ran a batch out of retries pinned that count and now
expect one retry after the first attempt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first attempt always happens, then up to `retries` retries with the
same back-off. retries="0" sends every batch once instead of dropping
it unsent, and the error line reports the real number of attempts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PetrHeinz
PetrHeinz merged commit 310b806 into main Sep 30, 2026
16 checks passed
@PetrHeinz
PetrHeinz deleted the claude/retry-count branch September 30, 2026 17:00
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.

1 participant