(code: number, reason: string)
| 154 | |
| 155 | sleep(progressiveDelay(retries)).then(() => { |
| 156 | const handleError = (code: number, reason: string) => { |
| 157 | if (conn.state === "closed" || conn.state === "ready") { |
| 158 | return; |
| 159 | } |
| 160 | if (conn.retries >= MAX_RETRIES) { |
| 161 | setConnState({ state: "closed" }); |
| 162 | reject( |
| 163 | `${messages.disconnected()}: max retries exceeded (${MAX_RETRIES}). code=${code} reason="${reason}"` |
| 164 | ); |
| 165 | return; |
| 166 | } |
| 167 | connect(resolve, reject); |
| 168 | }; |
| 169 | |
| 170 | const timer = setTimeout(() => { |
| 171 | handleError(-1, "timeout"); |
no test coverage detected