()
| 128 | } |
| 129 | |
| 130 | private async openLoop(): Promise<void> { |
| 131 | while (!this.stopped) { |
| 132 | this.emitStatus(this.lastStatus === "disconnected" || this.lastStatus === "reconnecting" || this.retryMs > 1000 ? "reconnecting" : "connecting") |
| 133 | try { |
| 134 | await this.openOnce() |
| 135 | this.retryMs = 1000 |
| 136 | return |
| 137 | } catch (error) { |
| 138 | if (!this.options.reconnect || (error instanceof RuntimeClientError && error.code === "unsupported_protocol_version")) throw error |
| 139 | this.emitStatus("reconnecting") |
| 140 | await delay(this.retryMs) |
| 141 | this.retryMs = Math.min(this.retryMs * 2, 15_000) |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | private openOnce(): Promise<void> { |
| 147 | return new Promise((resolve, reject) => { |
no test coverage detected