(retries: number, cause: unknown)
| 454 | } |
| 455 | |
| 456 | defaultReconnectStrategy(retries: number, cause: unknown) { |
| 457 | // By default, do not reconnect on socket timeout. |
| 458 | if (cause instanceof SocketTimeoutError) { |
| 459 | return false; |
| 460 | } |
| 461 | |
| 462 | // Generate a random jitter between 0 – 200 ms: |
| 463 | const jitter = Math.floor(Math.random() * 200); |
| 464 | // Delay is an exponential back off, (times^2) * 50 ms, with a maximum value of 2000 ms: |
| 465 | const delay = Math.min(Math.pow(2, retries) * 50, 2000); |
| 466 | |
| 467 | return delay + jitter; |
| 468 | } |
| 469 | } |
no outgoing calls
no test coverage detected