()
| 152 | } |
| 153 | |
| 154 | private scheduleReconnect(): void { |
| 155 | if (this.closed || this.reconnectAttempts >= this.maxReconnects) { |
| 156 | if (!this.closed) { |
| 157 | this.opts.onError( |
| 158 | new ApiError(0, "SSE connection permanently lost", "network") |
| 159 | ); |
| 160 | } |
| 161 | return; |
| 162 | } |
| 163 | const delay = Math.min(1_000 * Math.pow(2, this.reconnectAttempts), 30_000); |
| 164 | this.reconnectAttempts++; |
| 165 | this.reconnectTimer = setTimeout(() => this.connect(), delay); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | /** |