Referenceretry
Reference · 33
retry
retry
Re-subscribes on an error.
Signature
retry(count?: number | { count?: number; delay?: number | ((err, i) => ObservableInput) }): MonoTypeOperatorFunction
What it does
On a source error it recreates the subscription and tries again, up to count times. If all attempts are exhausted, the error is passed on. The delay config accepts a pause (a number of ms) or a function returning an Observable of "when to retry" — that gives backoff.
When to use
Network failures, transient 5xx errors, unstable services. Exponential backoff: retry({ count: 3, delay: (e, i) => timer(2 ** i * 1000) }).
Gotcha
Don't use it on Subjects/hot sources — recreating the subscription means re-sending the request / re-running the effect. An infinite retry with no logging hides the problem.
See also
catchError, timer, finalize
script.ts
CONSOLE · Console output
Hit Run to see the result...