···60606161Talking about increasing the `delay` randomly, `randomDelay` allows us to disable this. When this option is set to `false` we'll only increase the time between attempts with the `initialDelayMs`. This means if we fail the first time we'll have 1 second wait, next fail we'll have 2 seconds and so on.
62626363-We can declare how many times it should attempt the `operation` with `maxNumberAttempts`, otherwise, it defaults to 2. If you want it to retry indefinitely, you can simply pass in `Number.POSITIVE_INFINITY`.
6363+We can declare the maximum number of attempts (including the initial request) with `maxNumberAttempts`, otherwise, it defaults to 2 (which means one retry). If you want it to retry indefinitely, you can simply pass in `Number.POSITIVE_INFINITY`.
64646565[For more information on the available options check out the API Docs.](../api/retry-exchange.md)
6666
+1-1
docs/api/retry-exchange.md
···2424| `initialDelayMs` | Specify at what interval the `retrying` should start, this means that if we specify `1000` that when our `operation` fails we'll wait 1 second and then retry it. |
2525| `maxDelayMs` | The maximum delay between retries. The `retryExchange` will keep increasing the time between retries so that the server doesn't receive simultaneous requests it can't complete. This time between requests will increase with a random `back-off` factor applied to the `initialDelayMs`, read more about the [thundering herd problem](https://en.wikipedia.org/wiki/Thundering_herd_problem). |
2626| `randomDelay` | Allows the randomized delay described above to be disabled. When this option is set to `false` there will be exactly a `initialDelayMs` wait between each retry. |
2727-| `maxNumberAttempts` | Allows the max number of retries to be defined. |
2727+| `maxNumberAttempts` | Defines the maximum number of attempts (including the initial request). For example, `2` means one retry after the initial attempt. |
2828| `retryIf` | Apply a custom test to the returned error to determine whether it should be retried. |
2929| `retryWith` | Apply a transform function allowing you to selectively replace a retried `Operation` or return a nullish value. This will act like `retryIf` where a truthy value retries (`retryIf` takes precedence and overrides this function.) |
+3-3
exchanges/retry/src/retryExchange.ts
···4545 * @defaultValue `true` - enables random exponential backoff
4646 */
4747 randomDelay?: boolean;
4848- /** Specifies the maximum times an operation should be sent to the API.
4848+ /** Specifies the maximum number of attempts, including the initial request.
4949 *
5050 * @remarks
5151- * `maxNumberAttempts` defines the number of attempts an operation should
5252- * be retried until it's considered failed.
5151+ * `maxNumberAttempts` defines the total number of attempts before it's
5252+ * considered failed.
5353 *
5454 * @defaultValue `2` - Retry once, i.e. two attempts
5555 */