OptionalbaseBase delay for the first retry, in milliseconds. Default: 500ms.
OptionalmaxUpper cap on the computed delay before jitter, in ms. Default: 30s.
OptionalrngRandom number generator. Defaults to Math.random. Tests inject a deterministic RNG so delays are predictable.
Exponential backoff policy with full jitter, suitable for WebSocket reconnection. Each call to
nextDelay()returns the delay (in ms) before the next attempt, incrementing the internal attempt counter.Formula (full jitter, per AWS architecture blog): raw = min(maxDelay, baseDelay * 2^attempt) actual = random(0, raw)
This reduces thundering-herd when many clients reconnect simultaneously after the server comes back online.
Reset the counter via
reset()on successful connection.