(retries: number, cause: Error)
| 206 | } |
| 207 | |
| 208 | #shouldReconnect(retries: number, cause: Error) { |
| 209 | const retryIn = this.#reconnectStrategy(retries, cause); |
| 210 | if (retryIn === false) { |
| 211 | this.#isOpen = false; |
| 212 | publish(CHANNELS.ERROR, () => ({ |
| 213 | error: cause, |
| 214 | origin: 'client', |
| 215 | internal: false, |
| 216 | clientId: this.#clientId |
| 217 | })); |
| 218 | this.emit('error', cause); |
| 219 | return cause; |
| 220 | } else if (retryIn instanceof Error) { |
| 221 | this.#isOpen = false; |
| 222 | publish(CHANNELS.ERROR, () => ({ |
| 223 | error: cause, |
| 224 | origin: 'client', |
| 225 | internal: false, |
| 226 | clientId: this.#clientId |
| 227 | })); |
| 228 | this.emit('error', cause); |
| 229 | return new ReconnectStrategyError(retryIn, cause); |
| 230 | } |
| 231 | |
| 232 | return retryIn; |
| 233 | } |
| 234 | |
| 235 | async connect(): Promise<void> { |
| 236 | if (this.#isOpen) { |
no test coverage detected