* Reject any in-flight sends and mark the connection failed. Idempotent so * that close() and the underlying 'close'/'error' events do not double-reject. * @param {Error} error * @private
(error)
| 131 | * @private |
| 132 | */ |
| 133 | _failPending(error) { |
| 134 | if (this._closed) { |
| 135 | return |
| 136 | } |
| 137 | this._closed = true |
| 138 | this.connected = false |
| 139 | for (const { reject, timeoutId } of this._pending.values()) { |
| 140 | clearTimeout(timeoutId) |
| 141 | reject(error) |
| 142 | } |
| 143 | this._pending.clear() |
| 144 | // Reject any callers parked in waitForConnection() so close() (or an |
| 145 | // unexpected disconnect) cannot leave them hanging forever. |
| 146 | for (const { reject } of this._connectWaiters) { |
| 147 | reject(error) |
| 148 | } |
| 149 | this._connectWaiters.clear() |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * @returns {WebSocket} |
no test coverage detected