Retries with backoff

View as Markdown
Enterprise feature

This feature is available only for the Enterprise plan. To get started, reach out to support@buildwithfern.com.

Fern SDKs will automatically retry failed requests with exponential backoff. A request will be retried as long as the request is deemed retryable and the number of retry attempts has not grown larger than the configured retry limit.

Retryable status codes

A request is deemed retryable when any of the following HTTP status codes is returned:

  • 408 (Timeout)
  • 429 (Too Many Requests)
  • 5XX (Internal Server Errors)

Note that you can configure the list of retryable status codes as well. For example, if you want to remove the 429 status code from the list of retryable status codes, you can do so.

Overriding the retry limit

By default, the SDK will retry a failed request up to 2 times. SDK users can override the global default retry limit when instantiating the client.

1import { ImdbClient } from "imdb";
2
3const client = new ImdbClient({
4 maxRetries: 1 // overrides the default retry limit to 1
5});

It’s also possible to override the retry limit on a per-request basis.

1 client.movie.get("tt0111161", {
2 maxRetries: 3 // overrides the default retry limit to 3
3 });

Customizing the backoff schedule

The Java SDK exposes client builder options to tune the exponential backoff applied between retries, alongside maxRetries.

Java
1import com.imdb.ImdbClient;
2
3ImdbClient client = new ImdbClient.Builder()
4 .maxRetries(3)
5 .initialRetryDelayMillis(500)
6 .maxRetryDelayMillis(30000)
7 .retryJitterFactor(0.1)
8 .build();
OptionDescriptionDefault
initialRetryDelayMillisInitial delay in milliseconds used for exponential backoff.1000
maxRetryDelayMillisMaximum delay in milliseconds between retries.60000
retryJitterFactorJitter factor between 0 and 1 applied to retry delays.0.2