bridgeBackoff function

Duration bridgeBackoff(
  1. int attempt
)

Reconnect backoff for bridge clients: 1s doubling, capped at 30s.

Mirrors the DAP HubClient.defaultBackoff — the shift exponent is clamped BEFORE shifting, because 1 << 64 is 0 under Dart's 64-bit shift semantics and a huge attempt would otherwise collapse the delay to zero (a tight reconnect loop).

Implementation

Duration bridgeBackoff(int attempt) {
  final shift = (attempt - 1).clamp(0, 5);
  final seconds = 1 << shift;
  return seconds > 30
      ? const Duration(seconds: 30)
      : Duration(seconds: seconds);
}