In K2 2.8.3 you learned that a retry can double a POST, and you protected the TED import against duplicate entries. In K2 2.9.3, Aspire's service defaults brought along a resilience handler for every HttpClient, which reopened exactly this gap. You took it out there, and since then every client of the Kladde decides in its own registration. In this lesson you look at what this handler really does, when a retry helps and when it does harm. At the end, for every call of the Kladde it is documented how often it happens at most: Fetches are retried where that is safe, mails never.

New is a package that you already know from the service defaults:

Package Version What for
Microsoft.Extensions.Http.Resilience 10.11.0 the standard handler for HttpClient
Microsoft.Extensions.Resilience 10.11.0 Polly pipelines for work without HTTP

Both build on Polly, an open-source library for retries, time limits and circuit breakers. Microsoft's packages connect it with dependency injection, configuration and telemetry.

What is worth retrying

A retry helps only with an error that might no longer be there on the next attempt. Such errors are called transient. Everything else is permanent: The next attempt gets the same answer, only later.

Response Kind Why
No connection, connection dropped (HttpRequestException) transient a restart, a network error, a replica that is just being replaced
Time limit of one attempt transient an overloaded replica; the next one may be free
408 Request Timeout transient the server waited too long for the request
429 Too Many Requests transient you were too fast; Retry-After says how long to wait
500, 502, 503, 504 transient an error on the other side, often brief
400, 401, 403, 404, 409, 422 permanent the request itself is wrong, not allowed or contradicts the state

The standard handler treats exactly the first group as transient: connection exceptions, time limits of its attempts, 408, 429 and every status code from 500 up. It does not distinguish whether the retry is harmless for this call. That is your job, and that is what the rest of this lesson is about.